Versions Compared

Key

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

Image Removed

...

Anchor
top
top

An entity bean is defined as a representation of persistent data that has the ability to read from database and populate its fields with data. It can be updated and stored back to the database. There are two types: Bean-Managed Persistence(BMP) and Container-Managed Persistent(CMP). This article covers the migration of a BMP sample application. For this type of entity bean, actual code must be written to handle persistent operations such as loading, saving and finding data. The developer must use persistence API such as JDBC to select, insert, update, delete from a database.

...

BMP implementation may vary from one vendor to another. The purpose of this section is to provide a BMP specific feature-to-feature comparison between JBoss v4 and Apache Geronimo so you can clearly identify the differences and plan accordingly before migration.

Features

JBoss v4

Apache Geronimo M5

EJB Container

JBoss comes with its own EJB Container implementation.

Geronimo uses OpenEJB as its EJB Container.

JMS implementation

JBoss is packaged with JBoss MQ.

Geronimo uses ActiveMQ as its JMS implementation.

...

Sample application
Anchor
sampleApp
sampleApp

The Loan BMP application is very simple. When the command line client is run, an entry is made into the database. The findByPrimaryKey() method of the CustomerHomeRemote interface is called and the field values of the returned CustomerRemote object are printed to the console. This is followed by a call to the findBySssNo() method after which the field values of the returned CustomerRemote object are printed to the console.

The following figure illustrates the application flow:

Image RemovedImage Added

The user runs the command line client which then either creates an entity bean (which then adds itself to the datasource) or asks for one, by primary key, which is created from information that is stored in the database.

...

In order to build the loan application a Maven script has been provided. Download the Loan application from the following URL:link:

Loan BMP Samplehttp://opensource2.atlassian.com/confluence/oss/download/attachments/1148/loan-bmp.zip

After extracting the zip file, a loan-bmp directory will be created. From now on, this directory will be referred as <bmp_home>. In that directory open the project.properties file. Edit the maven.jboss.home property to match your environment.

...

You should see the following screen:

Image RemovedImage Added

Click on Add Customer. Enter the new customer information then click Create, this will take you to the first page showing the updated list of customers.

...

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

...

Configure Maven

You should set the maven.geronimo.home property in project.properties to point to your <geronimo_home> directory.

Back to Top

Step-by-step migration
Anchor
migration
migration

The same EJB jar

...

The same EJB jar file that was created and deployed in jboss may be deployed in Geronimo with no changes to its contents but you still need to edit the jndi properties of sample application. Edit the jndi.properties file located in in the <bmp_home>/jndi directory as shown in the following example:

...

Code Block
xml
xml
borderStylesolid
titlecustomer-ejb.xml
<?xml version="1.0" encoding="UTF-8"?>

<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/CustomerEJB/1.0/car"
    parentId="orggeronimo/apache/geronimo/SystemDatabasesystem-database/1.0/car">
 <enterprise-beans>
    <entity>
        <ejb-name>CustomerEJB</ejb-name>
        <jndi-name>CustomerHomeRemote</jndi-name>
        <local-jndi-name>CustomerRemote</local-jndi-name>
        <resource-ref>
            <ref-name>jdbc/ibm-demo</ref-name>
            <resource-link>SystemDatasource</resource-link>
        </resource-ref>
    </entity>
 </enterprise-beans>
</openejb-jar>

This plan sets orggeronimo/apache/geronimo/SystemDatabasesystem-database/1.0/car as the parent. What follows is the definition of the entity bean. The jndi-name element indicates the jndi name of the entity bean's home interface CustomerHomeRemote. This is the name that the Loan BMP sample application will lookup in the jndi context. The element local-jndi-name indicates the jndi name of the local interface, which in this case happens to be a remote interface, CustomerRemote. Next, a reference to the SystemDatasource is defined giving the application access to the database.

The Web Application client can be direclty directly deployed in Geronimo. This is because the build step packages both the JBoss jboss-web.xml and Geronimo geronimo-web.xml specific deployment plans in the war file. You can see both of these files in the <bmp_home>\src\webapp\WEB-INF directory.

...

Code Block
xml
xml
borderStylesolid
titleGeronimo deployment plan geronimo-web.xml
<web-app xmlns="http://geronimo.apache.org/xml/ns/web"
         xmlns:naming="http://geronimo.apache.org/xml/ns/naming"
         configId="geronimo/EntityDemoWebApp/1.0/car"
         parentId="geronimo/CustomerEJB/1.0/car">
         
    <context-root>entity-ejb</context-root>    
     
    <ejb-ref>
        <ref-name>ejb/CustomerHome</ref-name>
        <target-name>
             geronimo.server:EJBModule=MDBDemo,geronimo/CustomerEJB/1.0/car,
                 J2EEApplication=null,J2EEServer=geronimo,
                     j2eeType=EntityBean,name=CustomerEJB
        </target-name>
    </ejb-ref>
</web-app>

...