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

...

Anchortoptop
This article will help you migrate JDBC applications developed for JBoss v4.0.5 to Apache Geronimo v1.1 and is part of a series of migration articles covering different types of applications migration.

...

JDBC implementation analysis Anchor analysis analysis

JDBC implementation may 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

JBoss v4.05

Apache Geronimo

JDBC access

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

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.

JCA implementation

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

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

Data sources supported

Supports 5 types of data sources:

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

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

Data source 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

TranQL has specialized drivers for certain databases (including Apache Derby, Oracle and soon DB2) 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.

XA support

Supports XA transactions, Local Transactions, and No transaction.

Supports XA transactions, Local Transactions, and No transaction.

Connection Manager Configurability

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

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.

JTA implementation

Full support for JTA through JBossJTA.

Transaction support is provided through JOTM and HOWL.

Connection pooling and management

JBossCX framework used for connection pooling and management.

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

Legacy driver support

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

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

Sample application Anchor samplesample

This article contains a sample application to demonstrate the migration of 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 enviroment 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.

...

During the instance configuration I modified the security settings and specified "password" as the password for the root user. This user ID and password will later be used for accessing the database from the sample application.

...

Then enter your password to enter log in to the MySQL command interface as shown in the following example:

No FormatbgColor#000000borderStylesolid Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 15 to server version: 4.1.15-Debian_1ubuntu5-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>

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.

...

After extracting the zip file, a brokerage directory is created. In that directory open the build.properties file and edit the properties to match your environment as shown in the following example:

...

...

...

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 war-jboss. 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.

...

This brings up the login screen of the Online Brokerage application. Enter j2ee as the user name and password as the password and click on login. This takes you to the available stocks page illustrated in the following figure. The application is now configured and running.

...

...

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.

...

The Geronimo enviroment Anchor geronimogeronimo

Download and install Geronimo from the following URL:

...

The release notes available there provide clear instructions on system requirements and how to install and start Geronimo. Throughout the rest of this article we will refer to the Geronimo installation directory as <geronimo_home>.

...

...

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.

...

Configure resources

In Geronimo the JDBC resources are implemented using J2EE connectors. Therefore, you need to write a Geronimo specific deployment plan for deploying a JDBC datasource. Additionally, while doing the deployment you need to provide the deployer with the tranql-connector-1.2.rar file. This RAR file contains the connection pool management logic for Geronimo.

...

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.

...

Next user have to deploy database connection pool of the Geronimo. Given is the sample database pool deployment plan comes with this application. This configuration file is going to deploy as a Global datasource in the Geronimo server.

...

First part of this xml deployment plan is more of a Maven 2 configuration file. Following are some of the other important parts of the above deployment plan.

...

Now you are ready to proceed with the migration.

Step-by-step migration Anchormigrationmigration

Geronimo does not support accessing external resources(JDBC datasources) by setting JNDI properties at runtime.
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 need to 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/web/WEB-INF directory and looks like the following example. Note that naming:resource-ref element maps the TradeDS data source to the name jdbc/TradeDB in this deployment plan.

...

...

To build the Geronimo version of the application use ant war-geronimo in your command prompt. It will create the brokerage.war under the brokerage/releases/geronimo folder.

...

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

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.

...