HomeDocumentation > Apache Geronimo v1.0 - User's Guide > Migrating to Apache Geronimo > JBoss to Geronimo - JCA Migration


This article will help you migrate applications that are based on Java Connector Architecture (JCA) and developed for JBoss v4 to Apache Geronimo. It is part of a series of migration articles covering different types of applications migration.

This article provides some details on the differences between these two application servers as well as a detailed step-by-step migration procedure for porting JCA applications from JBoss v4 to Apache Geronimo. To define a common starting point (the source environment) we provide steps for deploying the sample File Retriever JCA application into the JBoss source environment. Then you will be guided through the application migration and deployment process onto Apache Geronimo.

This article is organized in the following sections:

JCA implementation analysis

Connectors implementation, also know as Resource Adapters, may vary from one vendor to another. The purpose of this section is to provide a JCA specific feature-to-feature comparison between JBoss and Apache Geronimo so you can clearly identify the differences and plan accordingly before migration.

The most common features related to support of Connectors are summarized in the following table:

Features

JBoss v4

Apache Geronimo

Basic JCA architecture support

Supports resource adapters. However, requires that the ra.xml deployment descriptor file specifies a class implementing javax.resource.spi.ResourceAdapter interface. Such an implementation is optional according to the specification.

Supports resource adapters exactly as it is expected according to the JCA specification

Location of classes

Compiled Java classes are to be put into the root of corresponding RAR archive similar to JAR files.

Fails to find classes just located in a RAR file. It needs the classes to be packed in an intermediate JAR file which in its time should be put into the root of the RAR archive.

Server-specific deployment descriptors

Uses *-ds.xml name convention and expects to find such a file in the deployment directory of the respective server outside corresponding EAR or RAR archive.

Allows to put additional deployment parameters into the geronimo-ra.xml file inside the META-INF folder of corresponding RAR archive. Also allows to specify external deployment plan files during deployment of resource adapters.

As it is shown in this table, JBoss requires an implementation of the ResourceAdapter interface. The fully-qualified name of a corresponding class should be specified in the ra.xml file, note the <resourceadapter-class> tags in the following example:

The class org.jboss.resource.deployment.DummyResourceAdapter is the dummy implementation of the interface provided by JBoss that can be used in those cases when the supplier of the adapter does not provide its own specific implementation. This implementation does nothing and returns null when invoked.

On the other hand, Geronimo follows the J2EE specification and does not require the resourceadapter-class element. However, Geronimo throws a java.lang.NullPointerException when attempting to use the dummy implementation of the interface which copies the stub provided by JBoss.

Back to Top

Sample application

This article contains a File Retriever JCA sample application to demonstrate the migration from JBoss to Geronimo. This application consists of two modules that, for this sample purposes, are deployed separately and not as a single EAR archive.

The first module is a simple file system resource adapter that conforms to the JCA architecture without any server-specific extensions. The adapter provides only two functions:

  • Lists name of files and directories located in a specific repository being a directory in the underlying file system.
  • Retrieves the content of one of the files.

The second module is a Web application that uses the adapter and provides online access to the files.

The user views a list of directories and files located in the repository and clicks a file to download it from the server. By default the resource adapter is configured so that the root directory of an application server is used as the repository.

Back to Top

Application classes and JSP pages

The JCA sample application consists of the following packages:

  • com.ibm.j2g.jca.connector - Interfaces for the resource adapter and its factory class.
  • com.ibm.j2g.jca.connector.impl - Implementation of the interfaces and auxiliary classes required by the JCA architecture.
  • com.ibm.j2g.jca.web - Classes of the Web module:
    • FileRetrieverServlet - Used for downloading files from the repository.

In addition to these packages, the Web module consists of a single JSP page which is located in the web directory. This JSP shows structure of the repository and provides hyperlinks to the File Retriever servlet for downloading contents of the files.

Back to Top

Tools used

The tools used for developing and building the File Retriever sample 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

The JBoss environment

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

Detailed instructions for installing, configuring, and managing JBoss are provided in the product documentation. Check the product Web site for the most updated documents.

The following list highlights the general tasks you will need to complete to install and configure the initial environment as the starting point for deploying the sample application.

  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

Compiling the source code of the sample application requires Java libraries that provide J2EE API interfaces. Build scripts included with the sample application package are configured for using JAR files provided by a JBoss installation.

The only additional software required for building the application is Apache Ant. If you still 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

Build the sample application

The File Retriever JCA sample application included with this article provides an Ant script that you will use in order to build modules of the application. Download the File Retriever JCA application package from the following link:

File Retriever JCA Sample

After extracting the zip file, a jca directory is created. From now on this directory will be referred as <jca_home>. In that directory open the build.properties file and edit the properties which starts from the prefix jboss to match your environment as shown in the following example. The remaining properties are not relevant at this point in time, you will use them later to build the Geronimo version of this sample application.

build.properties
# Name of the server to build the application for:
server.name = jboss

# Home directory of JBoss 4.0.2 J2ee Application Server
# and name of the server instance on which the application
# should be deployed (JBoss is also used for building
# purposes):
jboss.home = <jboss_home>
jboss.server = <your_server_name>

# Home directory of Geronimo Application Server
# and its administrator credentials:
geronimo.home = <geronimo_home>
geronimo.user = system
geronimo.password = manager

When specifying the directories and paths in the build.properties file, make sure to use just the forward slash "/" , otherwise the build will not locate the required files.

From a command prompt or shell go to the <jca_home> directory and run ant. This will create the RAR and WAR archives and place them directly into the <jca_home> directory.

Back to Top

Resource adapter descriptor

The RAR archive contains a JBoss version of the resource adapter deployment descriptor. The ra.xml file, located in the META-INF directory is shown in the following example.

ra.xml

This file provides general information about the resource adapter, specifies its interfaces and classes, defines repository path configuration parameter and declares that the adapter does not support transaction. In particular, since JBoss requires that the descriptor defines a class implementing javax.resource.spi.ResourceAdapter interface the dummy implementation org.jboss.resource.deployment.DummyResourceAdapter provided by JBoss itself is specified.

To deploy the adapter you also need a deployment descriptor specific to JBoss which is not included into the RAR archive because it may be updated just before deployment in order to provide the correct configuration for the adapter. The file <jca_home>/meta/jboss/jca-ds.xml providing the required configuration looks like the following example.

jca-ds.xml

This descriptor defines the JNDI name of the factory that is responsible for the resource adapter instance creation, it specifies that the adapter classes are contained by the jca.rar archive and provides value of the repository path configuration parameter. By default the adapter is configured so that the root directory of the JBoss server is used as the repository.

Web application descriptors

The WEB-INF directory of the WAR archive created by ant contains the standard web.xml deployment descriptor as well as a descriptor specific to JBoss, jboss-web.xml.

web.xml
jboss-web.xml

The web.xml file defines a servlet used for retrieving contents of files and locally used reference to the resource adapter which the main JSP page and the servlet refer to. The jboss-web.xml file defines the context root for the Web module and maps the locally used reference to the JNDI name defined by the resource adapter descriptor specific to JBoss, the jca-ds.xml file.

Back to Top

Deploy the sample application

To deploy the modules of the File Retriever JCA application on JBoss, place the jca.rar and jca.war files that you just built with ant, along with the <jca_home>/meta/jboss/jca-ds.xml file into the following directory:

<jboss_home>\server\<your_server_name>\deploy

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.

Test the sample application

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

http://localhost:8080/jca

This brings up the main page of the sample application. Click a file to download it from the repository.

Back to Top

The Geronimo environment

Download and install Geronimo from the following URL:

http://geronimo.apache.org/downloads.html

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

TCP/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

Step-by-step migration

To migrate the File Retriever sample application from JBoss to Geronimo you just need to update deployment descriptors and replace descriptors specific to JBoss with ones specific to Geronimo for both modules as described in the following sections.

Resource adapter descriptors

Geronimo follows the specification and does not require the resourceadapter-class element to be specified in the resource adapter deployment descriptor in case no implementation is available.

The Geronimo version of the ra.xml file is located in the <jca_home>/meta/geronimo directory. It is almost identical to the descriptor used by JBoss which is located in the <jca_home>/meta/jboss directory and was listed above. The only difference is that the Geronimo version does not include the following lines from the JBoss version.

Differences between JBoss and Geronimo resource adapters descriptors

To deploy the adapter on Geronimo you also need a deployment plan specific to this server. Such a plan can be either named geronimo-ra.xml and be placed into the META-INF folder of the corresponding RAR archive, or can have any name and stay outside the archive. In the latter case, the path to the plan should be specified during the deployment of the resource adapter.

The deployment plan used by the sample application contains the repository path configuration parameter that may be updated before the deployment. Because of this, the jca-plan.xml file is not included in the RAR archive but it is placed into the <jca_home>/meta/geronimo directory instead. The content of this file is listed in the following example.

jca-plan.xml

In this deployment plan the attribute configId specifies the unique name com/ibm/j2g/jca.rar used to identify the RAR module in Geronimo. The attribute parentId specifies that this module is deployed on the server as a separate component. Both attributes are required in this case.

The descriptor also:

  • Defines the FileRetriever name which looks up for the resource adapter factory.
  • Specifies that neither transactions nor connection pool are supported.
  • Provides value of the repository path configuration parameter.

By default, the adapter is configured so that the root directory of the Geronimo server is used as the repository.

Back to Top

Web application descriptors

To deploy the WAR module on Geronimo you need to replace the jboss-web.xml file with a similar descriptor specific to this server. The geronimo-web.xml file is located in the <jca_home>/web/WEB-INF directory and its contents is listed the following example.

geronimo-web.xml

In first place, this file specifies the unique name com/ibm/j2g/jca.war used to identify the WAR module in Geronimo and refers to the RAR module as to a parent configuration. This relation is required because the WAR module uses Java-interfaces defined in the RAR module.

Then, similar to JBoss, this descriptor also defines the context root for the Web application and maps the locally used reference ra/FileRetriever to the name of the resource adapter specified in its deployment plan (jca-plan.xml).

These are the only changes required to run modules of the JCA application in Geronimo.

Back to Top

Build the migrated sample application

In order to build the modules of the File Retriever JCA application for Geronimo, you need to update the build.properties file so that the server.name property value is set to geronimo and properties that start with the prefix geronimo match your environment as shown in the following example.

build.properties
# Name of the server to build the application for:
server.name = geronimo

# Home directory of JBoss 4.0.2 J2ee Application Server
# and name of the server instance on which the application
# should be deployed (JBoss is also used for building
# purposes):
jboss.home = <jboss_home>
jboss.server = <your_server_name>

# Home directory of Geronimo Application Server
# and its administrator credentials:
geronimo.home = <geronimo_home>
geronimo.user = system
geronimo.password = manager

Modifying the source code

If you modify the Java source code of this application, ensure that the properties which start with the prefix jboss still match your environment. The build scripts still refer to JBoss libraries for J2EE API interfaces required for the source code compilation. Alternatively, you can update the classpath specified in the build.xml file so that it refers to the library <geronimo_home>/repository/geronimo-spec/jars/geronimo-spec-j2ee-1.4-rc5.jar instead of JBoss JARs.

Now run the command ant build. This will create the Geronimo version of the RAR and WAR archives with the proper deployment descriptors and place them directly into the <jca_home> directory.

You can ensure that Java classes and interfaces for the resource adapter in the Geronimo version are packed into an intermediate JAR library which is placed into the RAR archive (while in the JBoss version the compiled Java code is placed into the archive directly). The reason for this is described in the beginning of this article.

Back to Top

Deploy the migrated sample application

To deploy the migrated File Retriever JCA application, make sure the Geronimo server is up and running.

From a command line, change directory to <jca_home> and type the following commands:

java -jar <geronimo_home>/bin/deployer.jar --user system --password manager deploy meta/geronimo/jca-plan.xml jca.rar

java -jar <geronimo_home>/bin/deployer.jar --user system --password manager deploy jca.war

Another way to deploy the modules on Geronimo (that is running on the default port 8080) is to update the build.properties file so that the properties which start with geronimo match with your environment and invoke the ant deploy command. The script executed by Ant will uninstall the modules if installed and deploy their latest builds created on the previous step.

E:\jca>ant deploy
Buildfile: build.xml

deploy:

deploy.geronimo:
     [java]         Module com/ibm/j2g/jca.war stopped.

     [java]         Module com/ibm/j2g/jca.war unloaded.

     [java]         Module com/ibm/j2g/jca.war uninstalled.

     [java]     Undeployed com/ibm/j2g/jca.war

     [java]         Module com/ibm/j2g/jca.rar stopped.

     [java]         Module com/ibm/j2g/jca.rar unloaded.

     [java]         Module com/ibm/j2g/jca.rar uninstalled.

     [java]     Undeployed com/ibm/j2g/jca.rar

     [java]     Deployed com/ibm/j2g/jca.rar

     [java]     Deployed com/ibm/j2g/jca.war @ http://hcunico:8080/jca


BUILD SUCCESSFUL
Total time: 7 seconds
E:\jca>

Once the JCA application is deployed, open a Web browser and access the following URL:

http://localhost:8080/jca

You should see the JSP page of the application which is similar to the page of the JBoss version which you have already tested. The only difference should be an actual contents of the repository.

Back to Top

Summary

This article showed how to migrate a JCA (resource adapter) application from JBoss v4 to the Apache Geronimo application server. It showed that the migration requires you to update deployment descriptors (provide descriptors specific to Geronimo server). This takes minimum efforts.

Back to Top