Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Image Removed
Article donated by: Henry Isidro, Leonard Flournoy, Hernan Cunico

...

Anchor
top
top

A typical J2EE application may contain Enterprise JavaBeans or EJBs. These beans contain the application's business logic and live business data. Although it is possible to use standard Java objects to contain your business logic and business data, using EJBs addresses many of the issues of using simple Java objects, such as scalability, lifecycle management and state management.

...

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

Apache Geronimo M5 (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

Not yet in M5, it will be available in V1supported

Access to EJBs from external CORBA objects

supported

supported

...

Sample application
Anchor
sampleApp
sampleApp

This sample application Session Bean Sample Application shows how session beans are used and deployed in a container. There are two clients, one for stateless session beans and another for stateful session beans. Both client applications use the same database which contains a table that stores loan application details. An entity bean is used to connect to and operate on the loan details table. A session bean is then used by the client application to get specific details from the database using the entity bean. The first client creates a stateless session bean and displays a list of denied loan applications via a method defined in that EJB. The second client creates a stateful session bean and adds loan applications to the database.

The following figure illustrates the application flow:

Image RemovedImage Added

Application Beans

...

Download the Session Bean sample application from the following URL:link:

Session Bean Samplehttp://opensource2.atlassian.com/confluence/oss/download/attachments/1155/session.zip

After extracting the zip file, a session directory will be created. From now on, this directory will be referred as <session_home>.

...

This will compile the source files and package the EJB jar file. You can see the results in the <session_home>/target directory. The following list shows the dependency jars needed in building and running the Session Bean sample application.

  • geronimo-spec-ejb-_2.1_spec-rc41.0.jar - the EJB spec; needed for compiling source.
  • openejb-core-2.0-G1M5.jar - needed by Geronimo during runtime.
  • geronimo-spec-j2ee-_1.4_spec-rc41.0.jar - needed by Geronimo during runtime.
  • geronimo-security-1.0-M5.jar - needed by Geronimo during runtime.

...

The following figures illustrate the home page for the Web Application as well as the testing for the stateless and stateful beans depending on your selection on the Web Application home page.

Image RemovedImage Added

Image RemovedImage Added

Image RemovedImage Added

Back to Top

The Geronimo environment
Anchor
Geronimo
Geronimo

...

CREATE TABLE CUSTOMER(ID INTEGER NOT NULL PRIMARY KEY,NAME VARCHAR(45),BIRTHDATE DATE,SSS_NO VARCHAR(25),ADDRESS VARCHAR(60),ANNUAL_SALARY DOUBLE,LOAN_AMOUNT DOUBLE)

Image RemovedImage Added

Back to Top

Step-by-step migration
Anchor
migration
migration

...

Code Block
xml
xml
borderStylesolid
titleopenejb-jar.xml
<openejb-jar
    xmlns="http://www.openejb.org/xml/ns/openejb-jar"
    xmlns:naming="http://geronimo.apache.org/xml/ns/naming"
    xmlns:security="http://geronimo.apache.org/xml/ns/security"
    xmlns:sys="http://geronimo.apache.org/xml/ns/deployment"
    configId="geronimo/SessionBeanDemo/1.0/car"
    parentId="orggeronimo/apache/geronimo/Serverj2ee-server/1.0/car">
 <enterprise-beans>
 	
    <entity>
        <ejb-name>CustomerEJB</ejb-name>
        <jndi-name>CustomerHomeRemote</jndi-name>
        <local-jndi-name></local-jndi-name>
        <resource-ref>
            <ref-name>jdbc/ibm-demo</ref-name>
            <resource-link>SystemDatasource</resource-link>
        </resource-ref>
    </entity>
    
    <session>
        <ejb-name>LoanManagerEJB</ejb-name>
        <jndi-name>LoanManagerHomeRemote</jndi-name>
        <ejb-ref>
            <ref-name>ejb/CustomerHomeRemote</ref-name>
            <ejb-link>CustomerEJB</ejb-link>
        </ejb-ref>        
   </session>
 	
 	<session>
        <ejb-name>StatefulLoanManagerEJB</ejb-name>
        <jndi-name>StatefulLoanManagerHomeRemote</jndi-name>
        <ejb-ref>
            <ref-name>ejb/CustomerHomeRemote</ref-name>
            <ejb-link>CustomerEJB</ejb-link>
        </ejb-ref>        
   </session>
   
 </enterprise-beans>
    
</openejb-jar>

As with all Geronimo deployment plans, this configuration requires a parent configuration. In this case, it is orggeronimo/apache/geronimo/Serverj2ee-server/1.0/car, then follows the definition of the EJBs.

...

As with JBoss, the following figures illustrate the home page for the Web Application as well as the testing for the stateless and stateful beans depending on your selection on the Web Application home page.

Image RemovedImage Added

Image RemovedImage Added

Image RemovedImage Added

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.2 to Apache Geronimo M5. This article provided step-by-step instructions to build the application, deploy and run it, and then migrate it to the Geronimo environment.

...