Saturday Mar 29, 2014
Wednesday Mar 26, 2014
By BrunoBorges-Oracle on Mar 26, 2014
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:
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:
- List JDBC resources from a GlassFish domain
- (optional; see below) Install 3rd-party JDBC drivers in WebLogic
- Extract and convert relevant and required information by WebLogic
- Create datasources inside WebLogic
Concepts of JDBC Resources
Listing JDBC Resources from a GlassFish domain
Extracting GlassFish's JDBC Connection Pool data
Create the Data Source in WebLogic using WLST
$ java weblogic.WLST ds_gf2wls.py
Extending and improving the migration process
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
Monday Mar 03, 2014
By BrunoBorges-Oracle on Mar 03, 2014
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.
Developer Installation of WebLogic 12c
- 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
Test your WebLogic 12c Developer Installation
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
The Beauty of Java EE 6
JPA and Database setup
- $ mysql -u root -p
- mysql> create database gf2wls;
- mysql> grant all privileges on gf2wls.* to gf2wls@localhost identified by 'gf2wls';
Import project to NetBeans, setup MySQL driver, and run it on GlassFish 188.8.131.52
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 clientThe sample Bookmark application comes with a JAX-WS WebService.
Running the sample Java EE 6 application in WebLogic 12c
- 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/.
- 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!
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
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
- JavaOne, Oracle OpenWorld, e JUG Tour Brasil 2015
- Trip Report: Porto Tech Hub 2015
- Nashorn Maven: Easy Library Classpath Setup
- Oracle Linux Docker Base Image on Ubuntu 14.10
- The Developers Conference 2014
- WebLogic Encrypt Tool Script for Remote and Cloud Servers
- O Futuro do Java no Windows XP
- Docker, Java EE 7, and Maven with WebLogic 12.1.3
- Java FAQ: Tudo o que você precisa saber
- Oracle no #TDC2014 Florianópolis