Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Anchortop
top This article will help you migrate JDBC applications developed for JBoss v4 to Apache Geronimo. This article is part of a series of migration articles covering different types of applications migration.

...

JDBC implementation analysis Anchorimplementationimplementation

JDBC implementation might vary from one vendor to another. The purpose of this section is to provide a JDBC specific feature-to-feature comparison between JBoss and Apache Geronimo so you can clearly identify the differences and plan accordingly before migration.

...

Feature

Apache Geronimo

JBoss v4

JDBC access

Geronimo does not have any direct integration with JDBC but supports access through the generic J2CA framework. The TranQL project has J2CA adapters for various databases.

JDBC access in JBoss is through JDBC connectors based on the JCA specification.

JCA implementation

Geronimo supports the JCA 1.5 specification and is backward compatible to the JCA 1.0 specification.

JBoss AS 4.0 implements the JCA (Java Connector Architecture) 1.5 specification instead of the JCA 1.0 in JBoss AS 3.2.

Data sources supported

TranQL has generic wrappers for data source, ConnectionPoolDatasource, and XADataSource.

Supports 5 types of data sources:

  • no-tx-datasource
  • local-tx-datasource
  • xa-datasource
  • ha-local-tx-datasource
  • ha-xa-datasource

Data source failover

TranQL has specialized drivers for certain databases (including Apache Derby, Oracle, MySQL, DB2 and SQL Server) that provide a tighter integration with the advanced features of the driver.
It is at this level that features such as load-balancing and failover would be provided. You can also use a C-JDBC wrapper for providing database clustering and failover.

JBoss has data source failover capabilities implemented through two data sources.
1) ha-local-tx-datasource - for local transactions.
2) ha-xa-datasource - for distributed transactions

XA support

Supports XA transactions, Local Transactions, and No transaction.

Supports XA transactions, Local Transactions, and No transaction.

Connection Manager Configurability

The J2CA framework is interceptor based which allows different parts of the connection framework to be plugged in.
Although you cannot plug in a custom connection manager now, this capability can be added fairly easily.

You can plug in your own custom connection manager if required.

JTA implementation

Transaction support is provided through JOTM and HOWL.

Full support for JTA through JBossJTA.

Connection pooling and management

Custom Geronimo Code and TranQL used for connection pooling and management.

JBossCX framework used for connection pooling and management.

Legacy driver support

Geronimo also provides this through the TranQL- connector JDBC to JCA wrapper in Geronimo. Supports JDBC 3.0 and 2.1.

JBoss provides connection to RDBMS that have not yet implemented JCA- JDBC drivers through JCA wrappers for JDBC drivers.

Back to Top

Sample application Anchor sampleAppsampleApp

This article contains a sample application to demonstrate migrating an application from JBoss to Geronimo, called Online Brokerage. It represents an online trading scenario in which users can buy and sell stocks. The application has the following five pages:

...

Back to Top

The JBoss environment AnchorJBossJBoss

This section shows you how and where the sample JBoss reference environment was installed so you can map this scenario to your own implementation.

...

This will bring up the MySQL command interface as shown in the following example:

...

...

From the MySQL command interface create the tradedb sample database by typing the following command:

...

Copy the mysql-ds.xml file to the deploy directory of your JBoss server (<jboss_home>\server\<your_server_name>\deploy) and edit it as shown in the following example:

...

...

Delete all the other tags inside the <local-tx-datasource> tag and save the file. JBoss will automatically deploy the data source.

...

...

When specifying the driver.classpath in the build.properties file, make sure to use just the forward slash "/" , otherwise the build will not find the jar file.

From a command prompt or shell go to the brokerage directory and run ant. This will build the war file and place it directly in the brokerage directory. The war created by the ant build contains a JBoss specific deployment descriptor, the jboss-web.xml file in the WEB-INF directory of the WAR is shown in the following example.

...

...

The resource-ref element is used to map the resource referred to by the name jdbc/TradeDB in the web.xml file to the resource with the JNDI name java:jdbc/TradeDB i.e. the MySQL datasource.

...

titlePro Tip

...

If you want to use another root password for the database, replace the occurrences of password with the required password. This has to be changed in the following three places:

  1. MySQL instance configuration.
  2. Data source configuration file.
  3. build.properties file used by the Ant build script.

...

Back to Top

The Geronimo environment Anchor GeronimoGeronimo

Download and install Geronimo from the following URL:

...

If you are planning to run JBoss and Geronimo on the same machine consider to change the default service ports on, at least, one of these servers.

...

The Geronimo repository is located at <geronimo_home>/repository. Inside this directory, create a directory called mysql/mysql-connector-java/3.1.14-bin and copy the mysql-connector-java-3.1.14-bin.jar file into it. Now, you create the data source deployment plan.

...

...

There are three types of data sources that Geronimo supports:

  • Global data source - Visible to all the applications on a Geronimo Instance.
  • Application scoped data source - Visible to a single application within which it is defined.
  • Module scoped data source - Visible to a single module within which it is defined.

For this migration exercise you will be using a Global data source. For instructions on configuring and using the other two types of data sources see the the following developerWorks article:

http://www.ibm.com/developerworks/opensource/library/os-ag-jdbc/

...

Back to Top

Create the data source deployment plan

First, create an xml file called mysql-geronimo-plan.xml. Copy the plan shown in the following example and paste it in the xml file.

...

The listing above shows the plan for deploying a J2EE connector which will provide JDBC access to the database. The root element is the <connector> element. This element has the following four attributes:

...

Back to Top

Step-by-step migration Anchormigrationmigration

Geronimo does not support accessing external resources(JDBC datasources) by setting JNDI properties at runtime as shown in the following example:

...

...

This is because reference resolution is done at deploy time and is based on the JSR-77 object names of the target component. In order to migrate the Online Brokerage application to Geronimo, you first replace the jboss-web.xml file with a geronimo-web.xml file which is the Geronimo-specific descriptor file.

The geronimo-web.xml file is located in the <brokerage_home>\web\descriptors\geronimo directory and looks like the following example.

...

...

As shown in the example, the parent for this configuration is the MySQL J2EE connector. The naming:resource-ref element maps the TradeDS data source to the name jdbc/TradeDB. The context-root element gives the context-root of the application.

...

Login with the same user name and password you used when testing the application from JBoss.

Back to Top

Summary Anchorsummarysummary

This article has shown you how to migrate a sample application, from JBoss to the Apache Geronimo application server. You followed step-by-step instructions to build the application, deploy and run it, and then migrate it to the Geronimo environment.

...