Versions Compared

Key

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

...

This article is organized in the following sections:

EJB implementation analysis
Anchor
#analysis
#analysis

EJB implementation may vary from one vendor to another. The purpose of this section is to provide a session bean 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.0.5

Apache Geronimo 2.1 (OpenEJB)

Stateful and stateless Session Beans

supported

supported

BMP (Bean Managed Persistence) Entity Beans

supported

supported

CMP (Container Managed Persistence) Entity Beans

supported

supported

Message driven beans (MDBs)

supported

supported

Interoperability using RMI-IIOP or JAXRPC

supported

supported

Ability to expose stateless session beans and MDBs as Web Services

supported

supported

Support for sending and receiving messages via Web Services

supported

supported

Easy provisioning and hot deployment of EJB and JMX-based Web Services

supported

supported

Access to EJBs from external CORBA objects

supported

supported

Back to Top

Sample application
Anchor
#sample
#sample

This is a simple eCommerce web site which sells computer related items in both retail and wholesale markets. To get the whole sale prices of items, customer has to buy at least given number of items. Otherwise he/she will get only retail prices of the item. End user of the application can add those items to their shopping cart. A stateless session bean has been used to manage the discount calculation business workflow activities while shopping cart of the application has been implemented with the help of a stateful session bean.

...

A customer of this application directly login to the item list page. It will give all the details of the items they have currently on their stock. To buy one of these items in the stock, use the Buy link which comes with each item. It will forward customer in to the Add Item to Cart web page. To proceed buying, customer has to enter the quantity of items he/she needs. If this quantity exceeds the minimum discount quantity, discounts will be granted and added items in to the customer's shopping cart. Shopping cart web page displays the list of items already added to the cart and it enables removing of items from the cart. This application will be not allow to add the same item shopping cart twise.

Application classes and JSP pages

  • org.apache.geronimo.samples.computer.dto
    • ItemDTO - Data transfer object for item related information between web and ejb tiers.
    • TransactionDTO - Data transfer object for shopping cart transaction related information between web and ejb tiers.
  • org.apache.geronimo.samples.computer.ejb
    • ItemServiceBean - Stateless session bean to handle item realated workflow activities.
    • ShoppingCartBean - Stateful session bean to handle shopping cart related activities fro shopping cart activities.
  • org.apache.geronimo.samples.computer.web
    • ItemServiceDispatchServlet - A servlet to dispatch item service related activities from front end to web tier.
    • ShoppingCartDispatchServlet - A servlet to dispatch shopping cart related activities from fron end to web tier.

...

  • buy_item.jsp - Accepts quantity of items customer buys.
  • error.jsp - Display error conditions of the application.
  • index.jsp - Forward in to the item list of the application.
  • list_items.jsp - Display list of items in the stock.
  • shopping_cart.jsp - List of transactions added to the shopping cart will be displayed.

Tools used

The tools used for developing and building the Computer acessories seller 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 enviroment
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. Note that for this migration example JBoss v4.0.5 was used.

...

  1. Download and install JBoss v4.0.5 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.0.5 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.

Install and configure prerequisite software

In order to build and run this sample application included in this article, you need to install and configure the Ant build tool.

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

Configure XDoclet

XDoclet is going to be used as build tool for the configuration file generation. It is an open source code generation engine. It enables Attribute-Oriented Programming for java. In short, this means that you can add more significance to your code by adding meta data (attributes) to your java sources. This is done in special JavaDoc tags.
Although XDoclet originated as a tool for creating EJBs, it has evolved into a general-purpose code generation engine. XDoclet consists of a core and a constantly growing number of modules. It is fairly straight forward to write new modules if there is a need for a new kind of component.
http://xdoclet.sourceforge.net/xdoclet/index.html

Just extract the latest version of the XDoclet and set the xdoclet.home parameter in to the build.properties file.

Build the sample application

The computer acessories selling application included with this article provides an Ant script that you will use in order to build the application. Download the computer acessories selling application from the following link:

...

From a command prompt or shell go to the computer directory and run ant jboss. This will build the ear file and place it directly in the releases/jboss directory.

Deploy the sample application

To deploy the sample application just copy the computer.ear will be created under the computer/releases/jboss folder to the <jboss_home>/server/<your_server_name>/deploy folder.

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:

...

Following is the demonstration of a shopping cart of the sample application.

Back to Top

The Geronimo enviroment
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

Step-by-step migration
Anchor
#migration
#migration

When you built the computer acessories selling sample application, Ant packaged the deployment descriptors for both JBoss jboss.xml and Geronimo openejb-jar.xml as they were already provided by the sample application. These files are located in the computer/config directory.

...

jboss-web.xml map the EJBs from their JNDI names as given the above while geronimo-web.xml uses directly EJB's name. The reference names given in each mapping will be used refer EJBs from the Servlets. web.xml file of the WAR file contains more information about each EJB reference name, which will be common to the both Geronimo and JBoss flavours of this application.

Build the sample application

Build the migrated Geronimo version of the sample application by running following command from the computer directory.
ant geronimo
It will create computer.ear file in the computer/releases/geronimo folder.

Deploy the migrated application

To deploy the migrated Computer acessories selling application, make sure the Geronimo server is up and running.

...

Once the application is deployed, open a Web browser and access the following URL:
http://localhost:8080/computer

Back to Top

Summary
Anchor
#summary
#summary

This article has shown how to migrate a sample application that uses Session Beans, from JBoss v4.0.5 to Apache Geronimo. This article provided step-by-step instructions to build the application, deploy and run it, and then migrate it to the Geronimo environment.

...