Wednesday Mar 26, 2014

Migrating JDBC Resources from GlassFish to WebLogic

Following up with my series of articles about Migrating from GlassFish to WebLogic, this time I want to cover the migration of a very common resource used by every Java EE developer: JDBC resources, or simply, DataSources. And in case you haven't read yet the first article, here it is: Migrating a Java EE App from GlassFish to WebLogic. That one will walk you through redeploying a simple yet almost complete Java EE 6 application on WebLogic, without any code change nor specific deployment descriptors, and still taking advantage of the enhanced Maven Plugin in WebLogic 12c.

It is easy to migrate resources by using the Web consoles of both WebLogic and GlassFish. Just open one browser window for each server, put them side-by-side, and follow the UI menus. Most of the properties are the same. But if you walkthrough the full article below, you will not only learn the concepts and what is required to migrate JDBC resources, but also how to migrate things using Command-line Interface (asadmin from GlassFish; wlst from WebLogic). So in order to understand what I'm doing here, I strongly recommend you to read, at least the introduction of, these two docs below in case you are not familiar with asadmin or wlst:


Oracle WebLogic Types of JDBC Data Sources

WebLogic offers three types of DataSources. For this migration, the type we will use will be "Generic". To know more about each type, click on the links below:

  • Generic Data Source
    • the type you are most familiar with; we will focus on this one
  • GridLink Data Source
    • in case you have an Oracle RAC Database, this is an optimal data source with HA and Failover features
  • Multi Data Source
    • abstracts two or more Generic Data Sources; works like a 'pool of data sources' so you can use it for either failover or load balancing



JDBC Resources: DataSources and Connection Pools

In the first article this was sort of covered from a Java EE Standard point of view. I simply took advantage of the @DataSourceDefinition annotation type, which allows developers to define JDBC DataSources directly from the Java source code, and requires no vendor-specific deployment descriptors nor manual previous configuration of the application server.

Now in case you have a legacy application or you are not using @DataSourceDefinition, you will be required to migrate these resources by hand. This will require three (plus one optional) simple steps:

  1. List JDBC resources from a GlassFish domain
  2. (optional; see below) Install 3rd-party JDBC drivers in WebLogic
  3. Extract and convert relevant and required information by WebLogic
  4. Create datasources inside WebLogic
Oracle WebLogic 12c already comes with JDBC drivers for Oracle DB 11g, MySQL 5.1.x, and Derby DB, so you won't need to do anything for these databases. For more information, read the docs JDBC Drivers Installed with WebLogic Server. In this doc you will also learn how to update the versions already provided by WebLogic, for example if you want to take advantage of the new features in Oracle DB 12c

If you are using Microsoft SQL Server, PostgreSQL, or any other database, check the Setting the Environment for a Thirdy-Party JDBC Driver for more information on how to install these drivers.

Concepts of JDBC Resources

We should also learn one difference between the concept of JDBC Resources in GlassFish 3 versus WebLogic 12c. In GlassFish, there are two types of JDBC Resources:
  • JDBC Connection Pools
  • JDBC Resources (aka DataSources)
On the other hand, WebLogic treats JDBC Resources as one single thing: Data Sources. The connection pool is part of the data source definition where in GlassFish, the Data Source is a separate artifact, which allows enabling/disabling the object, and also provides the JNDI name to a specific Connection Pool. In few words, when migrating a data source from GlassFish to WebLogic, you will only care about the JDBC Connection Pool and the JNDI name given at the JDBC Resource item.

Listing JDBC Resources from a GlassFish domain

First, let's list all JDBC Resources (datasources) in our GlassFish server. Connect with asadmin and execute thelist-jdbc-resources command:

asadmin> list-jdbc-resources
jdbc/__TimerPool
jdbc/__default
jdbc/gf2wls
Command list-jdbc-resources executed successfully.

Let's focus on our example: the jdbc/gf2wls datasource. This will be the DataSource we will migrate from GlassFish to WebLogic. Now let's list all Connection Pools in this GlassFish domain by using asadmin list-jdbc-connection-pools:

asadmin> list-jdbc-connection-pools
__TimerPool
DerbyPool
mysql_gf2wls_gf2wlsPool
Command list-jdbc-connection-pools executed successfully.

Now of course in case you have dozens of connection pools created in your GlassFish domain, it would be easier to issue a command that shows you which connection pool is associated to the Data Source you want to migrate. To do this, let's use the asadmin get command:

asadmin> get resources.jdbc-resource.jdbc/gf2wls.*
resources.jdbc-resource.jdbc/gf2wls.enabled=true
resources.jdbc-resource.jdbc/gf2wls.jndi-name=jdbc/gf2wls
resources.jdbc-resource.jdbc/gf2wls.object-type=user
resources.jdbc-resource.jdbc/gf2wls.pool-name=mysql_gf2wls_gf2wlsPool

We not only got which connection pool is associated to this data source but also its JNDI name, because the name of the resource may not be exactly the same as the JNDI name. 

Extracting GlassFish's JDBC Connection Pool data

Next step is to get all properties of your Connection Pool. Let's issue the asadmin get command again:

asadmin> get resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.*
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.portNumber=3306
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.serverName=localhost
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.databaseName=gf2wls
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.User=gf2wls
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.URL=jdbc:mysql://localhost:3306/gf2wls?zeroDateTimeBehavior=convertToNull
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.driverClass=com.mysql.jdbc.Driver
resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.Password=gf2wls
Command get executed successfully.

Easy, isn't? Now, let's focus on the minimum required properties we need to create this DataSource in WebLogic 12c. They are under resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.* , so if you want to list only these, change the asadmin method above to the following: asadmin get resources.jdbc-connection-pool.mysql_gf2wls_gf2wlsPool.property.*

Create the Data Source in WebLogic using WLST

To help you witht he final step, I've created a sample WLST script to create a Data Source in WebLogic. In this script, there are a few variables you must define. To call this script, go to your WebLogic installation directory and, if you are on Linux, call $ source setDomainEnv.sh (or the proper script for your environment). Then execute the WLST script: $ java weblogic.WLST ds_gf2wls.py

You should see the following output:

$ java weblogic.WLST ds_gf2wls.py
Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Connecting to t3://localhost:7001 with userid weblogic ...
...
Starting an edit session ...
Started edit session, please be sure to save and activate your 
changes once you are done.
Saving all your changes ...
Saved all your changes successfully.
Activating all your changes, this may take a while ... 
The edit lock associated with this edit session is released 
once the activation is completed.
Activation completed

That's it. Check your WebLogic Console, by going to the Data Sources page.

Extending and improving the migration process

Now you may be wondering how to improve the process by automating everything, right? Yes you can do that! Since we have been using CLI commands, it all depends now on you by tweaking and coding some bash scripts. For example, you can use asadmin to get the information of all Data Sources, generate a bunch of files, usesed to, you know, hack the output files, then loop through them and call a more dynamic WLST script. If you want to read files from WLST, here's a fragment you can use:

from java.io import FileInputStream

propIS = FileInputStream("MyGFDS.properties")
configDS = Properties()
configDS.load(propIS)

dsName=configDS.get("dsName")
dsFileName=configDS.get("dsFileName")
dsDatabaseName=configDS.get("dsDataBaseName")
datasourceTarget=configDS.get("datasourceTarget")
dsJNDIName=configDS.get("dsJNDIName")
dsDriverName=configDS.get("dsDriverName")
dsURL=configDS.get("dsURL")
dsUserName=configDS.get("dsUserName")
dsPassword=configDS.get("dsPassword")
dsTestQuery=configDS.get("dsTestQuery")

Migrating Advanced Settings

If you want to migrate advanced settings of the Connection Pool, take a look at the full list of properties I extracted from GlassFish in my sample Data Source. To change for example the Max Pool Size, tweak the WLST script and add the following:

dsMaxPoolSize=25

cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCConnectionPoolParams/' + dsName)
cmo.setMaxCapacity(dsMaxPoolSize)

Again, you can do whatever you want in WLST.

There you go! If you come up with a super awesome script to automate the whole process, let me know!

Monday Mar 03, 2014

Migrating a Java EE App from GlassFish to WebLogic

WebLogic is Oracle's strategic application server for the Java EE Platform. Since Oracle decided to focus on it for commercial support, and decided to leave GlassFish free of any ties with commercial decisions, I decided to bring this type of content to help GlassFish customers as well users to experiment, try, and evaluate Oracle WebLogic 12c (Java EE 6 certified).



But before getting down to the migration part, first thing you should learn is How to Install WebLogic 12c. For this migration tutorial in a developer environment, we will be using the Developer installation, but for production environments, we recommend the Full installation.

Full Installation
For full installation that can be used either in a production environment or in a developer environment, download the WebLogic Generic Installer and follow the steps descriped in the documentation for 12.1.2 on how to install WebLogic.

The difference between full and dev, is that full is targeted for any environment, and dev is well, for developers only. Oracle always recommend the full installation, but usually and specially for Java EE applications in a dev environment, the Development installation is enough. The good thing about it is the download size: less than 200Mb, and still you also get Oracle Coherence to play with. By the way, there is no licensing requirements for development purposes (either full or dev install), because WebLogic (and other Oracle products) are free for developers.

Required software

For this series of Migrating from GlassFish to WebLogic, I will be using NetBeans 8.0, GlassFish 3.1.2.2Oracle JDK 7, Oracle MySQL Community 5.6, and WebLogic 12.1.2. So make sure you have that software (except WLS for now) installed and configured in your system.

Developer Installation of WebLogic 12c

Let's get started by first installing WebLogic 12c for Developers. Instructions here are for Linux, but it is not that much different for Windows or Mac.
  1. Download WebLogic 12c ZIP Distribution for Developers (latest version: 12.1.2)
  2. Unzip it somewhere, for example:
    $ unzip wls1212_dev.zip -d /opt
  3. Go into the newly created directory
    $ cd /opt/wls12120
  4. Let's unpack the JAR files that were optimally compressed with pack200
    $ sh configure.sh    // for Windows, call configure.cmd
  5. After the uncompression, configure script will ask you if you want to create a new domain. Say "yes" by pressing 'y', then [enter]
  6. Provide a username, a password, and then confirm again the password
  7. Wait for the domain to be created and started
In just a few minutes you will have WebLogic installed, configured, and running!

Test your WebLogic 12c Developer Installation

At this point, you should have a WebLogic domain configured, up, and running. You can access the Admin Web Console at the following URL: http://localhost:7001/console. It will ask for username/password you typed during install. Take a moment to explore the Admin Console. You can find more information at the official documentation for 12.1.2.

You may also find very useful to know you can manipulate all domain settings through the WebLogic Scripting Tool, a command-line interface for you to code in Python, and issue commands to view and edit all settings. In an upcoming version of WebLogic we will also provide a REST interface.

I will use WLST in the next posts in this series, so maybe you want to read more later.

How to Start/Stop WebLogic 12c

In order to start and stop correctly your WebLogic domain, you can either do that from an IDE such as NetBeans, or by running specific scripts. These scripts are located under the following path location:

/opt/wls12120/user_projects/domains/mydomain/bin
  • $ sh startWebLogic.sh
  • $ sh stopWebLogic.sh

The Beauty of Java EE 6

Now, instead of going through the process of creating a Java EE application, I coded a small application that covers a large set of Java EE 6 APIs and pushed it to this GitHub repository. It is an application using the following APIs:
  • CDI 1.0
  • JSF 2.1
  • Bean Validation 1.0
  • EJB 3.1
  • JPA 2.0
  • JAX-WS 2.2
  • JAXB 2.2
  • JAX-RS 1.1
The beauty of Java EE is that you will learn from this migration how good it is when you follow standards, and also the value of the platform. Simply put: we will migrate this application without touching any code. At least not for now. Let's first set some infrastructure requirements. For now, we must have a database.

JPA and Database setup

To facilitate things, and before you can run this application, make sure you have MySQL installed and running onlocalhost, and with a database named gf2wls with username/password gf2wls with all privileges. The project comes with a drop-and-create configuration when JPA (through EclipseLink) is initialized.

To setup this, connect as root to your local MySQL server and issue the following two commands:
  1. $ mysql -u root -p
  2. mysql> create database gf2wls;
  3. mysql> grant all privileges on gf2wls.* to gf2wls@localhost identified by 'gf2wls';
And you are set!

Import project to NetBeans, setup MySQL driver, and run it on GlassFish 3.1.2.2

Since this is an article about migrating from GlassFish to WebLogic, I will assume you know how to get this application running on GlassFish 3.1.2.2 from NetBeans. But I will provide some highlights to make it work smoothless.



In order for the @DataSourceDefinition entry inside class InitializeSampleDataSessionBean work fine and connect to your MySQL database in GlassFish, make sure you have copied MySQL JDBC Driver into glassfish3/glassfish/domains/domain/domain1/lib/ext/ of course, before starting it up. In WebLogic, you don't need to do this since MySQL Connector/J is already part of the default installation.

Download the project 'bookmark-javaee6' to your local machine by either cloning the GitHub repository locally, or by downloading the zip and extracting somewhere. This is an Apache Maven project, so don't worry about environment. Just make sure you have this project up and running on a GlassFish domain.

Import the project bookmark-javaee6 into your NetBeans environment. Right click on bookmark-javaee6 project and select Run. Test the application by going to http://localhost:8080/bookmark-javaee6.

You should by now looking at the following screen:


Test the Bookmark WebService with a simple client

The sample Bookmark application comes with a JAX-WS WebService.

  1. You can test this WebService in many ways, but I will give you three main options: one is to try SoapUI
  2. Another option is to right click on the WebService in NetBeans, and select Test WebService
  3. Last option is to run the bookmark-javaee6-wsclient that comes with JUnit Test Cases. 
Make your choice, and see it working!

Running the sample Java EE 6 application in WebLogic 12c

Before we go to a pure Maven description on how to do this, let's give NetBeans a try. Now that you have everything ready (a Java EE 6 application running on GlassFish 3.1.2.2), with source code as a Maven project in NetBeans, let's add WebLogic as a Server to it.

  1. Go to the Services tab in NetBeans, and right click in Servers, then select Add Server....
  2. Select Oracle WebLogic Server
  3. Insert the path location of your recently installed WebLogic server. Remember to select the subfolderwlserver. If you installed as described in the beginning, you should try /opt/wls12120/wlserver
  4. Type your username and password of your WebLogic domain
  5. Finish this wizard
Now we must change from GlassFish to WebLogic in Project Properties. Select bookmark-javaee6 project and right click on it. Go to Run and select your newly created WebLogic 12.1.2 server. Press OK. See the picture below to understand what has to be done:



Start your project by right clicking in it, and select Run! Test your application running on WebLogic by going to the following location: http://localhost:7001/bookmark-javaee6


In case you had any problem, try these two articles:


Success! You have now the same application running on WebLogic 12c! Without any code change!

WebLogic understands GlassFish Deployment Descriptor

I haven't mentioned this before because I wanted you to see the sample application up and running on WebLogic, but what you can do in this application is to remove src/main/webapp/WEB-INF/weblogic.xml, and change the context-root inside glassfish-web.xml. What will happened if you redeploy this application without weblogic.xml, is that the application will start just fine, but in a different context-root: the one you typed inside glassfish-web.xml.

The reason for this is well documented on Support for GlassFish Deployment Descriptors. Give it a look in case you want to know what else does WebLogic understands from GlassFish's DD.

Now, let's try something different. Let's now use pure Apache Maven to compile and run the application on your WebLogic installation! For that, we will first need to configure the plugin.

Configuring the WebLogic Development Maven Plugin

Before you can use the plugin, you must install it in your local or remote Maven repository. Feel free to follow official instructions for WebLogic 12.1.2. But in case you want to just get it done, here's the short version:

  1. Go to your WLS installation. It is probably located here:
    /opt/wls12120
  2. Now change to the following directory:
    $ cd oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.2
  3. Issue the following command to sync WLS Maven Plugin into your local repository:
    $ mvn com.oracle.maven:oracle-maven-sync:push -Doracle-maven-sync.oracleHome=/opt/wls12120/oracle_home/.
You have now successfully installed WLS Maven Plugin. To validate the installation, type:
$ mvn help:describe -DgroupId=com.oracle.weblogic-DartifactId=weblogic-maven-plugin -Dversion=12.1.2-0-0

To continue, let's configure the plugin onto our bookmark-javaee6 sample application, and then deploy the package into WebLogic
  1. Open the POM file of bookmark-javaee6 project
  2. Uncomment the WebLogic Maven Plugin definition
  3. Make sure to enter the same username and password as your domain when you installed and configured WebLogic
  4. Make sure WebLogic is running
  5. Make sure there's no other bookmark-jaavaee6 project deployed on your WebLogic instance
  6. Execute the following command:
    $ mvn package pre-integration-test
  7. Check your logs and try http://localhost:7001/bookmark-javaee6!

Conclusion

As you could see, if you are working with a Java EE 6 project 100% standardized, and perhaps Maven, you will find no problems at migrating this project to WebLogic 12c. In fact, if you are using Maven it will be as simple as adding a new plugin just to facilitate deployment. But even this you won't have to do in case you have a binary only. Just open the Admin Web Console, and fire a deployment from there!

And by the way, WebLogic is not that heavyweight and unproductive application server developers thought it still is. For more information about Developer Productivity with WebLogic 12c, read my entry "WebLogic in Comparison: RebelLabs and the Java App Server Debate".

Caveats for Java EE projects, road ahead for migrations

In the next blog posts of this series, I will cover how to work around some common issues when your project is not exactly following, or taking advantage of all standards defined in the Java EE 6 platform, or simply using extra features, customizations of GlassFish.

Here's a sneak peek of what's coming next:
  • How to Migrate JDBC DataSources from GlassFish to WebLogic
  • How to Define, Deploy, and Use JMS resources
  • How to Migrate JMS resources from GlassFish to WebLogic
  • How to Add and Isolate (classpath of) 3rd-party libraries (for example PrimeFaces)
And many more things to come!
  • Applying a GlassFish Domain Topology to a WebLogic Domain (clustering, etc)
  • Migrating Security Realms
  • Migrating Custom Login Modules
If there's any other subject you'd like to see, please post a comment!

Cheers!

Wednesday Nov 06, 2013

6 Facts About GlassFish Announcement

Since Oracle announced the end of commercial support for future Oracle GlassFish Server versions, the Java EE world has started wondering what will happen to GlassFish Server Open Source Edition. Unfortunately, there's a lot of misleading information going around. So let me clarify some things with facts, not FUD.


Fact #1 - GlassFish Open Source Edition is not dead

GlassFish Server Open Source Edition will remain the reference implementation of Java EE. The current trunk is where an implementation for Java EE 8 will flourish, and this will become the future GlassFish 5.0. Calling "GlassFish is dead" does no good to the Java EE ecosystem. The GlassFish Community will remain strong towards the future of Java EE. Without revenue-focused mind, this might actually help the GlassFish community to shape the next version, and set free from any ties with commercial decisions.


Fact #2 - OGS support is not over

As I said before, GlassFish Server Open Source Edition will continue. Main change is that there will be no more future commercial releases of Oracle GlassFish Server. New and existing OGS 2.1.x and 3.1.x commercial customers will continue to be supported according to the Oracle Lifetime Support Policy. In parallel, I believe there's no other company in the Java EE business that offers commercial support to more than one build of a Java EE application server. This new direction can actually help customers and partners, simplifying decision through commercial negotiations.


Fact #3 - WebLogic is not always more expensive than OGS

Oracle GlassFish Server ("OGS") is a build of GlassFish Server Open Source Edition bundled with a set of commercial features called GlassFish Server Control and license bundles such as Java SE Support. OGS has at the moment of this writing the pricelist of U$ 5,000 / processor. One information that some bloggers are mentioning is that WebLogic is more expensive than this. Fact 3.1: it is not necessarily the case. The initial edition of WebLogic is called "Standard Edition" and falls into a policy where some “Standard Edition” products are licensed on a per socket basis. As of current pricelist, US$ 10,000 / socket. If you do the math, you will realize that WebLogic SE can actually be significantly more cost effective than OGS, and a customer can save money if running on a CPU with 4 cores or more for example. Quote from the price list:


“When licensing Oracle programs with Standard Edition One or Standard Edition in the product name (with the exception of Java SE Support, Java SE Advanced, and Java SE Suite), a processor is counted equivalent to an occupied socket; however, in the case of multi-chip modules, each chip in the multi-chip module is counted as one occupied socket.”


For more details speak to your Oracle sales representative - this is clearly at list price and every customer typically has a relationship with Oracle (like they do with other vendors) and different contractual details may apply.


And although OGS has always been production-ready for Java EE applications, it is no secret that WebLogic has always been more enterprise, mission critical application server than OGS since BEA. Different editions of WLS provide features and upgrade irons like the WebLogic Diagnostic Framework, Work Managers, Side by Side Deployment, ADF and TopLink bundled license, Web Tier (Oracle HTTP Server) bundled licensed, Fusion Middleware stack support, Oracle DB integration features, Oracle RAC features (such as GridLink), Coherence Management capabilities, Advanced HA (Whole Service Migration and Server Migration), Java Mission Control, Flight Recorder, Oracle JDK support, etc.

Update 24-11-2013:  clustering support is available on WebLogic Enterprise and Suite editions.

Fact #4 - There’s no major vendor supporting community builds of Java EE app servers

There are no major vendors providing support for community builds of any Open Source application server. For example, IBM used to provide community support for builds of Apache Geronimo, not anymore. Red Hat does not commercially support builds of WildFly and if I remember correctly, never supported community builds of former JBoss AS. Oracle has never commercially supported GlassFish Server Open Source Edition builds. Tomitribe appears to be the exception to the rule, offering commercial support for Apache TomEE.


Fact #5 - WebLogic and GlassFish share several Java EE implementations

It has been no secret that although GlassFish and WebLogic share some JSR implementations (as stated in the The Aquarium announcement: JPA, JSF, WebSockets, CDI, Bean Validation, JAX-WS, JAXB, and WS-AT) and WebLogic understands GlassFish deployment descriptors, they are not from the same codebase.


Fact #6 - WebLogic is not for GlassFish what JBoss EAP is for WildFly

WebLogic is closed-source offering. It is commercialized through a license-based plus support fee model. OGS although from an Open Source code, has had the same commercial model as WebLogic. Still, one cannot compare GlassFish/WebLogic to WildFly/JBoss EAP. It is simply not the same case, since Oracle has had two different products from different codebases. The comparison should be limited to GlassFish Open Source / Oracle GlassFish Server versus WildFly / JBoss EAP.


But the message now is much clear: Oracle will commercially support only the proprietary product WebLogic, and invest on GlassFish Server Open Source Edition as the reference implementation for the Java EE platform and future Java EE 8, as a developer-friendly community distribution, and encourages community participation through Adopt a JSR and contributions to GlassFish.


In comparison

Oracle's decision has pretty much the same goal as to when IBM killed support for Websphere Community Edition; and to when Red Hat decided to change the name of JBoss Community Edition to WildFly, simplifying and clarifying marketing message and leaving the commercial field wide open to JBoss EAP only. Oracle can now, as any other vendor has already been doing, focus on only one commercial offer.


Some users are saying they will now move to WildFly, but it is important to note that Red Hat does not offer commercial support for WildFly builds. Although the future JBoss EAP versions will come from the same codebase as WildFly, the builds will definitely not be the same, nor sharing 100% of their functionalities and bug fixes. This means there will be no company running a WildFly build in production with support from Red Hat.


This discussion has also raised an important and interesting information: Oracle offers a free for developers OTN License for WebLogic. For other environments this is different, but please note this is the same policy Red Hat applies to JBoss EAP, as stated in their download page and terms. Oracle had the same policy for OGS.


TL;DR;

GlassFish Server Open Source Edition isn’t dead. Current and new OGS 2.x/3.x customers will continue to have support (respecting LSP). WebLogic is not necessarily more expensive than OGS. Oracle will focus on one commercially supported Java EE application server, like other vendors also limit themselves to support one build/product only. Community builds are hardly supported. Commercially supported builds of Open Source products are not exactly from the same codebase as community builds.


What's next for GlassFish and the Java EE community?

There are conversations in place to tackle some of the community desires, most of them stated by Markus Eisele in his blog post. We will keep you posted.

Thursday Jul 25, 2013

Como instalar o GlassFish 4.0 (ZIP) [pt_BR]

O jeito mais rápido e fácil de instalar o GlassFish 4 em servidores é utilizando a versão ZIP do instalador. O ZIP já vem com um domínio (domain1) configurado, e por isso o tamanho do arquivo é maior que o instalador nativo (onde um domínio será configurado durante a instalação).

Passo-a-passo

  1. Entre em http://www.glassfish.org/downloads e clique no link abaixo de Zip (quick start). No momento deste post, a versão disponível é a 4.0.
  2. Descompacte o ZIP em um diretório de trabalho:
    $ mkdir ~/Work
    $ cd ~/Work
    $ unzip ~/Downloads/glassfish-4.0.zip
  3. Entre no diretório bin do GlassFish:
    $ cd glassfish4/bin
  4. Execute o seguinte comando para inicializar o domínio domain1
    $ bash asadmin start-domain domain1
  5. Abra o seu navegador e vá para o endereço http://localhost:4848

Pronto! Servidor up and running!

Tuesday Jun 04, 2013

Promote Java EE 7 and GlassFish on your Twitter

The launch of Java EE 7 is right ahead. On June 12th we will hear from Oracle executives and evangelists what's all about the new version of the platform. The Live Webcast "Introducing Java EE 7" will have two sessions, and all you need to do to join us and watch Arun Gupta and others, is to go to this webpage and sign up. Also, don't forget to check GlassFish's blog, you know, because it's the reference implementation of Java EE! :-)

But if you really, really love Java EE and really, really want people to join us, why don't you also promote the launch on your Twitter account? Use this background image that fits very nice on your profile, and also don't forget to set the background color to #517E9C.

Let's Make The Future Java... Together!

Monday Apr 22, 2013

What's new in Java EE 7 at JUDCon Brazil 2013

This weekend I talked about Java EE 7 at JUDCon Brazil 2013, the session "What's new in Java EE 7? From HTML5 to JMS 2.0". What a great honour to be at JBoss Users and Developers Conference to share with attendees the great work that Oracle, Red Hat, and many others are doing for this platform. Room was packed, with people standing, and so much interest to hear all the cool stuff to come, such as WebSockets, JMS, JAX-RS, JSF and even more. To add some value to this talk, and as I'm a fan of Game of Thrones, I thought that a few images would fit right at this talk :-)


Slides here!

Wednesday Apr 10, 2013

Configure DataSources for Maven Embedded GlassFish

 

In my previous post I showed to you how to configure Maven and the Embedded GlassFish Plugin to be run with GlassFish 4.0 b83. A comment on that post raised the following question: Is it now possible to setup datasources with GlassFish embedded for testing purposes? The answer is yes! Not only DataSource but any resource. For now, I only tested DataSources but it's working fine. Follow these steps:

  1. Create a file called glassfish-resources.xml inside your WEB-INF webapplication directory with the connection pool and datasource configured, by either:
    1. Adding the content of this Gist into it and edit it with your database information, or ...
    2. Create it using NetBeans as described in this blog post by Arun. Move the file to the src/webapps/WEB-INF folder.
  2. Make sure the JNDI name is similar to this: java:app/jdbc/YourDataSourceName and that it is correctly mapped in your persistence.xml

The most important thing here is to keep the JNDI name with java:app/ prefix. I tried using just jdbc/MyDS on both persistence.xml and glassfish-resources.xml, but it didn't work, shoulting errors in the log related to the __pm suffix issue. So remember the prefix, as this is an application-scoped resource.

UPDATE Also, don't forget to add the following dependency for your Database JDBC Driver inside the <plugin> of Embedded GlassFish. For MySQL, add this:

                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>5.1.24</version>
                    </dependency> 

 

Tuesday Apr 09, 2013

GlassFish 4 beta and Maven Embedded Plugin

Everyone is looking for an easy way to try out Java EE 7, even before the launch. Specially now where some JSRs just got Final, like JMS, Batch, JSON, and others. Arun already gave a great tip for anyone that want to try a Java EE 7 project with Maven, but the archetype offered by the Mojo project at Codehaus is missing one important thing: the Maven Plugin for GlassFish Embedded.

 

This plugin is great because developers don't even need to download, install and configure GlassFish locally. All they need to do is to have JDK and Maven installed. Then they can choose whatever IDE works best (I'm working right now with NetBeans, but I'm also a Sublime Text 2 big fan). It's a simple 3-step command:

  1. $ git clone http://myrepo/myproject
  2. $ cd myproject
  3. $ mvn embedded-glassfish:run
    ... then you wait until the Internet is being downloaded into your local repository ...

Done! Simple as that, a project that does not depend on any installation besides Maven and JDK (ok... Git too, in this case). Now how does the pom.xml must be set up with the Embedded plugin? Follow these steps:

  1. Create a project based on Codehaus archetype, like Arun mentioned in his blog. I'm copying the command line here for the sake of browser history:
    mvn -DarchetypeGroupId=org.codehaus.mojo.archetypes -DarchetypeArtifactId=webapp-javaee7 -DarchetypeVersion=0.3-SNAPSHOT -DarchetypeRepository=https://nexus.codehaus.org/content/repositories/snapshots/ -DgroupId=org.glassfish -DartifactId=javaee7-sample -Dversion=1.0-SNAPSHOT -Dpackage=org.glassfish.javaee7-sample -Darchetype.interactive=false --batch-mode --update-snapshots archetype:generate 
  2. Now open pom.xml, and go to the end of the <plugins> section
  3. Add the following plugin to the <build><plugins> section
    <plugin>
           <groupId>org.glassfish.embedded</groupId>
             <artifactId>maven-embedded-glassfish-plugin</artifactId>
             <version>3.1.2.2</version>
             <configuration>
                <app>target/${project.artifactId}-${project.version}</app>
                <port>8282</port>
                <contextRoot>${project.artifactId}</contextRoot>
             </configuration>
             <dependencies>
               <dependency>
               <groupId>org.glassfish.main</groupId>
               <artifactId>simple-glassfish-api</artifactId>
               <version>4.0-b79</version>
             </dependency>
             <dependency>
               <groupId>org.glassfish.main.extras</groupId>
               <artifactId>glassfish-embedded-all</artifactId>
               <version>4.0-b83</version>
             </dependency>
           </dependencies>
         </plugin>
  4. UPDATE 04-10-2013: Don't forget to add the following pluginRepository configuration inside your POM
       <pluginRepositories>
            <pluginRepository>
                <id>maven.java.net</id>
                <name>Java.net Repository for Maven</name>
                <url>https://maven.java.net/content/groups/promoted/</url>
            </pluginRepository>
            <pluginRepository>
                <id>maven2-repository.dev.java.net</id>
               <name>Java.net Repository for Maven</name>
                <url>http://download.java.net/maven/glassfish/</url>
            </pluginRepository>
        </pluginRepositories>
  5. Execute the following Maven command and then point your browser to http://localhost:8282/javaee7-sample
    $ mvn package embedded-glassfish:run

The reason you must modify the dependencies of the plugin is that there's no released yet of the Embedded Plugin pointing to the GlassFish 4 promoted builds, although some artifacts are already there (i.e. simple-glassfish-api for b79; version is different because until now, there's no release of b83). We hope that the plugin will be updated together with the official release, as soon as possible.

By the way, with this configuration of the Embedded Plugin, you can edit any JavaServer Faces page, and just hit refresh in the browser. The configuration is poiting to the exploded WAR in Maven's target directory. Great setup for designers. 

Happy Java EE 7 coding until the launch!

 

 

Wednesday Dec 12, 2012

7 reasons you had to be at JavaOne Latin America 2012

Yesterday was 12/12/12, and everybody went crazy on Twitter with cool memes like this one. And maybe you are now wondering why I mentioned 7 (seven) on the blog title. Because I want to play numbers? Yes! Today is 7 days after JavaOne Latin America 2012 is over (... and I had to figure out an excuse for taking so long to blog about it...).

So unless you were at JavaOne Latin America this year, here are 7 things you missed:

  1. OTN Lounge mini-theatre
    There was a mini-theatre holding several lightning talks. We had people from SouJava JUG, GoJava JUG, Globalcode, and several other Java gurus and companies running demos, talks, and even more. For example, @drspockbr talked about the ScrumToys project, that demonstrates the power of JSF.



  2. Hands On Lab for JAX-RS and WebSockets
    One of the cool things to do during JavaOne is to come to these Hands On labs and really do something using new technologies with the help of experts. This one in particular, was covered by me, Arun Gupta, and Reza Rahman. The HOL had more people than laptops (and we had 48 laptops!) interested on understanding and learning about the new stuff that is coming within Java EE 7. Things like JAX-RS, Server-sent Events and WebSockets. Hey, if you want to try this HOL by yourself, it is available on Github, so go for it! If you have questions, just let me know!



  3. Java Community Keynote
    This keynote presented a lot of cool things like startups using Java in their projects, the Duke Awards, SouJava winning the JCP Outstanding Award, the Java Band, and even more! It was really a space where the Java community could present what they are doing and what they want to do. There's a lot of interest on the Adopt-a-JSR program and the Adopt-OpenJDK. There's also an Adopt-a-JavaEE-JSR program! Take a look if you want to participate and Make the Future Java.

    DSC_1572.JPG

  4. Java EE (JMS, JAX-RS) sessions from Reza Rahman, the HeavyMetal guy
    Reza is a well know professional and Java EE enthusiast from the communitty who just joined Oracle this year. His sessions were very well attended, perhaps because of a high interest on the new things coming to Java EE 7 like JMS 2.0 and JAX-RS 2.0. If you want to look at what he did at this JavaOne edition, read his blog post. By the way, if you like Java and heavymetal, you should follow him on Twitter as well! :-)

  5. Java EE (WebSockets, HTML5) sessions from Arun Gupta, the GlassFish guy
    If you don't know Arun Gupta, no worries. You will have time to know about him while you read his Java EE 6 Pocket Guide. Arun has been evangelizing Java EE for a long time, and is now spreading his word about the new upcoming version Java EE 7. He gave one talk about HTML5 Productivity on the Java EE 7 platform, and another one on building web apps with WebSockets. Pretty neat! Arun blogged about JavaOne Latin America as well. Read it here.

  6. Java Embedded and JavaFX
    If there are two things that are really trending in the Java World right now besides Java EE 7, certainly they are JavaFX and Java Embedded. There were 14 talks covering Java Embedded, from Java Cards to Raspberry.pi, from Java ME to Java on your TV with Ginga-J. The Internet of Things is becoming true, and Java is the only platform today that can connect it all in an standardized and concise way. JavaFX gained a lot of attention too. There were 8 sessions covering what the platform has to offer in terms of Rich User Experience. The JavaFX Scene Builder is an awesome tool to start playing designing an UI, and coding for JavaFX is like coding Swing with 8 hands, one holding your coffee cup. You can achieve a lot, with your two hands (unless, you really have 8 hands, then you can achieve 4 times more :-). If you want to read more about JavaFX, go to Stephen Chin's blog post.

    DSC_1533.JPG

  7. GlassFish and Friends Party, 1st edition at JavaOne Lating America
    This is probably the thing that I'm most proud. We brought to Brasil the tradition of holding a happy hour for all GlassFish, Java EE friends. This party started almost 7 years ago in San Francisco, and it was about time to bring it to Brazil! The party happened on Tuesday night, right after JavaOne General Keynote, at the Tribeca Pub. We had about 80 attendees and met a lot of Java EE developers there! People from JUGs, Oracle, Locaweb and Red Hat showed up too, including some execs from Oracle that didn't resist and could not miss a party like this one.

    Lots of caipirinhas, beer and food to everyone, some cool music... even The Fish walking around the party with Juggy!



    You can see more photos from the party on an album I shared with the recently created GlassFish Brasil community on Google+ here (but you may be more interested in joining the GlassFish english community). There's also more pictures that Arun took and shared on this link.

So now you may want to consider coming to Brazil next year! Java EE 7 is on its way, and Brazil is happily and patiently waiting for it, with a lot of enthusiasm.

By the way, GlassFish and Java EE 6 just celebrated a Happy Birthday!

Wednesday Nov 28, 2012

GlassFish and Friends Party, 1st Edition at JavaOne Brasil

Estamos muito contentes em anunciar que iremos realizar a primeira edição da tradicional  GlassFish and Friends Party neste JavaOne in Brasil.  
O problema é que os ingressos já esgotaram!

Então decidimos realizar um concurso para dar mais 5 ingressos para a comunidade! Aqui estão as regras:

  1. Escreva um post no seu blog sobre o GlassFish
  2.  Poste no Twitter o título e o link do seu post com a hashtag #GlassFish para que possamos saber do seu post
  3. Os 5 melhores posts serão selecionados e anunciados aqui no dia 3 de Dezembro às 19:00 (GMT-3)
  4. Selecionaremos um post de cada autor
  5. Cada autor receberá um ingresso para a festa

Agora corre para a sua plataforma de blog e escreva sobre o GlassFish!

------------- en_US --------------- 

We are very happy to announce that we are going to host the first edition of the traditional GlassFish and Friends Party at this JavaOne in Brasil

The problem is: tickets are already SOLD OUT! 

So we decided to run a simple contest to give away 5 more tickets to the community! Here are the rules:

  1. Blog about GlassFish
  2. Tweet the title and link of your blog post with the hashtag #GlassFish so we can know about your blog post
  3. The best 5 blog posts will be selected and announced here on December 3th at 7pm (GMT-3)
  4. We will select one blog post per author
  5. Each author will get one ticket
Now run to your blog platform and write about GlassFish!

Wednesday Sep 26, 2012

JavaOne 2012: Camel, Twitter, Coherence, Wicket and GlassFish

Before joining Oracle as Product Manager for WebLogic and GlassFish for Latin America, at the beggining of this year I proposed two talks to JavaOne USA that I had been presenting in Brazil for quite a while. One of them I presented last year at ApacheCon in Vancouver, Canada as well in JavaOne Brazil. In June I got the news that they were accepted as Alternate Sessions. Surprisingly enough, few weeks later and at the same time I joined Oracle, I received the news that they were officially accepted and put on schedule.

Tomorrow I'll be flying to San Francisco, to my first JavaOne in the United States, and I wanted to share with you what I'm going to present there.
My two sessions are these ones:

  1. Wed, 10/03, 4:30pm - CON2989 Leverage Enterprise Integration Patterns with Apache Camel and Twitter

    On this one, you will be introducted to the Apache Camel framework that I had been talking about in Brazil at conferences, before joining Oracle, and to a component I contributed to integrate with Twitter. Also, you will have a preview of a new component I've been working on to integrate Camel with the Oracle Coherence distributed cache.

  2. Thu, 10/04, 3:30pm - CON3395 How Scala, Wicket, and Java EE Can Improve Web Development

    This one I've been working on for quite a while. It was based on an idea to have an architecture that could be as agile as frameworks and technologies such as Ruby on Rails, PHP or Python, for rapid web development. You will be introduced to the Apache Wicket framework, another Apache project I enjoy working with and gave lots of talks at Brazilian conferences, including JavaOne Brazil, JustJava, QCon SP, and The Developers Conference. You will also be introduced to the Scala language and how to create nice DSLs to boost productiveness. And last but not least, the Java EE 6 platform, that offers an awesome improvement from previous versions with its CDI, JPA, EJB3 and JAX-RS features for web development.

Other events I will be participating during my stay in SF:

  1. Geeks Bike Ride
  2. GlassFish Community Event
  3. GlassFish and Friends Party 

 

If you have any other event to suggest, please do suggest! It's my first JavaOne and I'm really looking forward to enjoying everything.

See you guys in a few days!!

Friday Aug 03, 2012

Issue dev'ing RESTful JSON services on NetBeans

Here is a tricky issue that you may find if you are developing RESTful services with Java EE on NetBeans and GlassFish or WebLogic. If you want to support the JSON format but need to access some implementation classes like @JsonIgnore, you need to add the JAX-RS RI, Jersey, to your project's Libraries definition. How to add the RI? You will probably do this:

  1. Open project's Properties (right click on the project)
  2. Go to Libraries
  3. Click on 'Add Library'
  4. Select 'Jersey 1.8 (JAX-RS RI)

But you won't have your service running fine. You may find these exceptions: (added here so Google can help future users)

1 - If you try to access your RESTful service to get a JSON format of it, you will get this exception:

com.sun.jersey.spi.inject.Errors$ErrorMessagesException
  at com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170)
  at com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136)
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199)

2 - If you try to access your RESTful service to get an XML format, you will get this exception:

java.lang.RuntimeException: javax.naming.NameNotFoundException: Unable to resolve 'com.sun.jersey.config.CDIExtension'. Resolved 'com.sun.jersey.config'; remaining name 'CDIExtension'
  at com.sun.jersey.server.impl.cdi.CDIExtension.getInitializedExtension(CDIExtension.java:177)
  at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactory.(CDIComponentProviderFactory.java:92)
  at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.initialize(CDIComponentProviderFactoryInitializer.java:75)
  at com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:576)
  at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:311)

 If you look at your server's log, (in my case, I was using WebLogic 12c) you may find this message somewhere:

WARNING: 
**********
The application is using ServletContainerInitializer class com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer that is loaded from:file:/labs/wls1211/modules/com.sun.jersey.server_1.1.0.0_1-9.jar. This initializer overrides the one available in the system.
**********

When you added Jersey to your library, the "package" checkbox was checked by default. So the JAR ended up going into WEB-INF/lib of your project, conflicting to the already provided by the container. 

So, how to fix this issue? Follow these steps:

  1. Open project's Properties (right click on the project)
  2. Go to Libraries
  3. Uncheck the checkbox 'Package' for Jersey 1.8 (JAX-RS RI)
  4. Click on 'OK'
  5.  Clean & Build (right click on the project) ---> remember to clean and rebuild your project
  6. (re)Deploy application

Done! :_)

 

About


Bruno has been having fun working with Java since 2000 and now helps Oracle on sharing the technology accross all Latin America. Also plays videogames, does trekking and loves beer.

Follow me on Twitter! @brunoborges

Search

Archives
« July 2015
SunMonTueWedThuFriSat
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
       
Today