Chapter 39. How to Migrate the New World Cruises Application to JOnAS

This section describes the modifications required to migrate the J2EE application "New World Cruise" to a JOnAS server.

"New World Cruise" is a sample application that comes with Sun ONE Application Server. (See http://developers.sun.com/sw/building/tech_articles/jaxrpc/synopsis.html.)

39.1. JOnAS Configuration

The first step is to configure the database used for this application. Copy the file db.properties to the directory $JONAS_BASE/conf. Edit this file to complete the database connection.

Then, modify the JOnAS DBM database service configurations in the file $JONAS_BASE/conf/jonas.properties, to specify the file containing the database connection.

39.1.1. New World Cruise Application

39.1.1.1. EJB Modification Code

To be EJB2.0-compliant, add the exceptions RemoveException and CreateException for EJB's methods ejbRemove and ejbCreate.

Additionally, the GlueBean class uses a local object in GlueBean constructor. However, it must use a remote object because it is a class calling an EJB. Therefore, modify the comment in this class with the following:

// If using the remote interface, the call would look like this
cruiseManagerHome = (CruiseManagerHome)
  javax.rmi.PortableRemoteObject.narrow(result, CruiseManagerHome.class);
// Using the local interface, the call looks like this
//cruiseManagerHome = (CruiseManagerHome) result;

39.1.2. EJB's Deployment Descriptor

There are three EJBs, thus there must be three ejb-jar.xml files that correspond to the EJB's deployment descriptors and three jonas-ejb-jar.xml files that correspond to the JOnAS deployment descriptors.

First, rename the files ejb_name.ejbdd with ejb_name.xml (these files contain the EJB deployment descriptors).

Create the three jonas-ejb_name.xml files corresponding to the EJBs.

For the two entity Beans (Cruise and CruiseManager), describe the mapping between:

  • The EJB name and JNDI name (JNDI name=ejb/ejb name)

  • The JDBC and the table name

  • The EJB field and the table field, (the version of CMP is not specified in ejb-jar and JOnAS by default uses CMP1.1).

For the session Bean, describe the mapping between:

  • The EJB name and JNDI name (JNDI name=ejb/ejb name)

39.1.3. Web Application

Create the jonas-web.xml that corresponds to the deployment descriptor of the New World Cruise application. Package the jonas-web.xml and the files under the directory Cruises/cruise_WebModule in the WAR file.

39.1.4. Build Application

Build the EAR corresponding to the application.

This EAR contains the three files corresponding to the three EJBs, as well as the web application.