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.

...

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.

...

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

...

Back to Top

The Geronimo environment 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.

...

Back to Top

Configure resources

...

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/

...

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:

...

where brokerage_home is the path of the brokerage directory.This will deploy the data source.
Now you are ready to proceed with the migration.

Back to Top

Step-by-step migration Anchor migration migration

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.

...