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.
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
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.
- Download WebLogic 12c ZIP Distribution for Developers (latest version: 12.1.2)
- Unzip it somewhere, for example:
$ unzip wls1212_dev.zip -d /opt
- Go into the newly created directory
$ cd /opt/wls12120
- Let's unpack the JAR files that were optimally compressed with pack200
$ sh configure.sh // for Windows, call configure.cmd
- After the uncompression, configure script will ask you if you want to create a new domain. Say "yes" by pressing 'y', then [enter]
- Provide a username, a password, and then confirm again the password
- 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:
- $ sh startWebLogic.sh
- $ sh stopWebLogic.sh
The Beauty of Java EE 6
- 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:
- $ mysql -u root -p
- mysql> create database gf2wls;
- 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 188.8.131.52
Since this is an article about migrating from GlassFish to WebLogic, I will assume you know how to get this application running on GlassFish 184.108.40.206 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
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.
- You can test this WebService in many ways, but I will give you three main options: one is to try SoapUI.
- Another option is to right click on the WebService in NetBeans, and select Test WebService.
- 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 220.127.116.11), with source code as a Maven project in NetBeans, let's add WebLogic as a Server to it.
- Go to the Services tab in NetBeans, and right click in Servers, then select Add Server....
- Select Oracle WebLogic Server
- 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
- Type your username and password of your WebLogic domain
- 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:
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:
- Go to your WLS installation. It is probably located here:
- Now change to the following directory:
$ cd oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.2
- 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
- Open the POM file of bookmark-javaee6 project
- Uncomment the WebLogic Maven Plugin definition
- Make sure to enter the same username and password as your domain when you installed and configured WebLogic
- Make sure WebLogic is running
- Make sure there's no other bookmark-jaavaee6 project deployed on your WebLogic instance
- Execute the following command:
$ mvn package pre-integration-test
- Check your logs and try http://localhost:7001/bookmark-javaee6!
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!