Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This article is organized in the following sections:

JDBC implementation analysis
Anchor
implementation
implementation

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

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

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

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:

...

New users can register by clicking the Register button in the login page. In the Registration page the user will enter a user id, user name, password, address and available cash.

Back to Top

Application classes and JSP pages

The Online Brokerage sample application consists of the following packages:

...

  • login.jsp - The login page of the application.
  • error.jsp - The default error page of the application.
  • register.jsp - The user registration page.
  • stocks.jsp - The Available Stocks page from where the user can buy stocks.
  • userstocks.jsp - The user portfolio page which shows the user's stocks. The user can sell stocks from this page.

Back to Top

Tools used

The tools used for developing and building the Online Brokerage application are:

Eclipse

The Eclipse IDE was used for development of the sample application. This is a very powerful and popular open source development tool. Integration plug-ins are available for both JBoss and Geronimo. Eclipse can be downloaded from the following URL:
http://www.eclipse.org

Apache Ant

Ant is a pure Java build tool. It is used for building the war files and populating the database for the Online Brokerage application. Ant can be downloaded from the following URL:
http://ant.apache.org

Back to Top

Sample database

The database used for demostrating this application is MySQL. The sample database name is tradedb and it consists of the following three tables, STOCKS, USERS and TRADINGACCOUNT. The fields for each of these tables are described below.

...

The DDL file used for populating this database is db.sql and it is located in the brokerage/sql directory.

Back to Top

The JBoss environment
Anchor
JBoss
JBoss

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

...

  1. Download and install JBoss v4 as explained in the product documentation guides. From now on the installation directory will be referred as <jboss_home>
  2. Create a copy of the default JBoss v4 application server. Copy recursively <jboss_home>\server\default to <jboss_home>\server\<your_server_name>
  3. Start the new server by running the run.sh -c <your_server_name> command from the <jboss_home>\bin directory.
  4. Once the server is started, you can verify that it is running by opening a Web browser and pointing it to this URL: http://localhost:8080. You should see the JBoss Welcome window and be able to access the JBoss console.
  5. Once the application server is up and running, the next step is to install and configure all the remaining prerequisite software required by the sample application. This step is described in the following section.

Back to Top

Install and configure prerequisite software

In order to build and run the Online Brokerage application included in this article, you need to install and configure the build tool and the database that is used by the application.

Install the database

As mentioned earlier in the article, this application is using the MySQL database that can be downloaded from the following URL:
http://www.mysql.com
The Installation and configuration of MySQL is fairly intuitive and it is well documented in the MySQL Reference Manual available at the following URL:

...

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

Create sample database

Once the MySQL instance is configured you need to create the sample database that will be used by the Online Brokerage application. From a command line, type the following command to start the MySQL monitor:

...

mysql> create database tradedb;

Configure Ant

As mentioned before, Apache Ant is used to build the binaries for the Online Brokerage application. If you do not have Ant installed this is a good time for doing it and make sure that <ant_home>\bin directory is added to the system's path variable.

Apache Ant can be downloaded from the following URL:

http://ant.apache.org

Back to Top

Configure resources

In order to successfully build and deploy the Online Brokerage application and database, you will first need to configure some resources. This section describes how to configure a MySQL data source in JBoss.

Data source

The Online Brokerage application is a Web application that uses a data source to connect to the MySQL database. To use JBoss with MySQL you need to copy the MySQL driver into the JBoss server classpath. The driver, which is provided by the database vendor, is called Connector/J 3.0 and can be downloaded from the following URL:
http://dev.mysql.com/downloads/connector/j/3.1.html

...

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

Back to Top

Build the sample application

The Online Brokerage application included with this article provides an Ant script that you will use in order to build the application and populate the database. Download the Online Brokerage application from the following link:

...

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.

Back to Top

Deploy the sample application

To deploy the Online Brokerage application in JBoss, copy the brokerage.war file you just built with Ant to the following directory:

...

If JBoss is already started, it will automatically deploy and start the application; otherwise, the application will be deployed and started at the next startup.

Back to Top

Test the sample application

To test the application, open a Web browser and access the following URL:

...

Tip
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
Geronimo
Geronimo

Download and install Geronimo from the following URL:

...

Warning
titleTCP/IP ports conflict

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

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-ra-1.3.rar file. This RAR file contains the connection pool management logic for Geronimo.

For running the Online Brokerage application in Geronimo, you will be using the same MySQL database that was used with JBoss. So the only task you need to do in order to prepare the Geronimo environment is to configure the data source.

Configure the data source

The first thing you need to do is to copy the MySQL database driver into the Geronimo repository so that you can refer to it in the data source deployment plan.

...

Info
titleDifferent types of data sources

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.

...

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:

...

The build.properties is used by the build script to pick up the J2EE specs for Geronimo. If your jboss.home property is still valid, it is not required to set this property. If this property is not set and the jboss.home is also not valid then you will get compilation errors. You also need to set the driver.classpath to point to the new driver jar. Now from the command prompt go to the brokerage directory and run ant. This builds the war file and places it directly in the brokerage directory.

Back to Top

Deploy the migrated sample application

To deploy the migrated Online Brokerage application, make sure the Geronimo server is up and running.

...

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

Back to Top

Summary
Anchor
summary
summary

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.

...

  1. In the Geronimo specific deployment descriptor the resource reference name is mapped to the name of the datasource unlike in the JBoss specific deployment descriptor where the resource name is mapped to the JNDI name of the datasource.
  2. In order to deploy a datasource in JBoss you need to just copy the configuration file to the deploy directory but in Geronimo you need to use the deployer tool.
  3. At this time, Geronimo does not support accessing external resources (i.e.:JDBC datasources) by setting JNDI properties at runtime. This resources need to be specified at deployment time.

Back to Top