Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

The Phone Book Bean Example

...

And, as usual their is an empty constructor for the Entity Bean

...

...

MyPhonebookLocal.java is the business interface that drives the above mentioned Entity Bean.

...

...

MyPhonebookBean.java is where the implementation of the local (and if there is, a the remote) interface. To explain what the annotations in this Stateless Session Bean means I will enumerate them:

  1. @Stateless - tells Geronimo that this is a stateless session bean
  2. @PersistenceUnit - tells Geronimo to retrieve a persistence unit defined in the persistence.xml and place it in the EntityManagerFactory note

    Note that PersistenceContext is used when you are directly obtaining a EntityManager. For an EntityManagerFactory use PersistenceUnit.

...

...

index.jsp is the JSP page that uses the EJB to access the database.

...

...

Deployment Plans for EJB

openejb-jar.xml just specifies the module's information.

...

...

persistence.xml will specify the name of the PersistenceUnit. This name is used when referencing for the EntityManagerFactory. I have denoted it as PhonePU. For some reason I could not get it to reference with jta-data-source. So the alternative method is to explicitly specify the ConnectionURL, ConnectionDriverName, and ConnectionUserName. I added an extra property called SynchronizeMappings so that the data in the database will not be overwritten.

SEE BELOW FOR POSSIBLE SOLUTION

...

...

Deployment Plans for Web-App

web.xml references the EJB by specifying the package to which the MyPhonebookLocal belongs to.

...

geronimo-web.xml specifies the module's information and the context-root for the web-app.

...

...

Deployment Plan for the application

geronimo-application.xml tells the application that there is a database pool that needs to be deployed as well. The db pool is defined in PhoneBookPool.xml and the driver that is needs in order to be deployed is the tranql-connector-ra-1.3.rar file--these two files will reside on the top level layer of the resultant EAR file.

...

...

Configuring, Building, and Deploying the Application

...

After starting Apache Geronimo log into the console and follow the given steps to create the PhoneBookDB.

...

  1. Select DB Manager link from the Console Navigation in the left.
  2. Give the database name as PhoneBookDB and click Create button.
  3. Select PhoneBookDB to the Use DB field.
  4. Open PhoneBookDB.sql in the myphonebook/myphonebook-ear/src/main/resources directory from a text editor.
  5. Paste the content PhoneBookDB.sql to the SQL Commands text area and press Run SQL button.

...

1. Include the module name in the app dependencies so geronimo knows to look in the new datasource module for the datasource. So, the openejb-jar.xml should look something like:

...

...

2. specify the name of the datasource in persistence.xml, something like

...