Versions Compared

Key

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

...

The following article provides concept-rich documentation on how to use JNDI to access connection pools for data sources, Java Messaging Services (JMS), mail sessions, and URL connections: Apache Geronimo JNDI naming and Java resource connection pools, Part 1: Data source connections. URL: http://www-128.ibm.com/developerworks/opensource/library/os-ag-jndi1Image Removed

However, the mentioned article is written for Geronimo 1.x. This sample tutorial will demonstrate something similar but using EJB 3.0.

...

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

<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1"
             xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1"
             xmlns:security="http://geronimo.apache.org/xml/ns/security-1.1"
             xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2">
   <dep:environment>
      <dep:moduleId>
         <dep:groupId>default<groupId>${pom.groupId}</dep:groupId>
         <dep:artifactId>ProcessCustomerSession<artifactId>${pom.artifactId}</dep:artifactId>
         <dep:version>1.0<version>${version}</dep:version>
         <dep:type>jar</dep:type>
      </dep:moduleId>

      <dep:dependencies>
      </dep:dependencies>
      <dep:hidden-classes/>
      <dep:non-overridable-classes/>
   </dep:environment>
</openejb-jar>

...

Code Block
xml
xml
borderStylesolid
titlegeronimo-application.xml
<application xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-1.1">
   <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
      <dep:moduleId>
         <dep:groupId>default<groupId>${pom.groupId}</dep:groupId>
         <dep:artifactId>CustomerService<artifactId>${pom.artifactId}</dep:artifactId>
         <dep:version>1.0<version>${version}</dep:version>
         <dep:type>ear</dep:type>
      </dep:moduleId>

      <dep:dependencies/>
      <dep:hidden-classes/>
      <dep:non-overridable-classes/>
   </dep:environment>
   
   <module>
       <connector>tranql-connector-ra-1.3.rar</connector>
       <alt-dd>CustomerServicePool.xml</alt-dd>
   </module>
   
</application>

...

Code Block
xml
xml
borderStylesolid
titleapplication.xml
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" version="5">
  <description>Geronimo Sample EAR for CustomerService</description>
  <display-name>Geronimo Sample EAR for CustomerService</display-name>
  <module>
    <ejb>CustomerService-ejb-2.0-SNAPSHOT.jar</ejb>
  </module>
  <module>
    <web>
      <web-uri>CustomerService-war-2.0-SNAPSHOT.war</web-uri>
      <context-root>/CustomerService<service</context-root>
    </web>
  </module>
  <module>
    <connector>tranql-connector-ra-1.3.rar</connector>
  </module>
</application>

...

After decompressing the given file, the CustomerService directory will be created.

Configuring

Source Code

You can checkout the source code of this sample from SVN:

svn checkout http://svn.apache.org/repos/asf/geronimo/samples/trunk/samples/CustomerService

Configuring

Configuration of the application consists of creating the database Configuration of the application consists of creating the database and defining the connection pool to access it.

Creating and Populating Database

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

Creating and Populating Database

...

No Format
borderStylesolid
titleCustomerService.sql

create table customer (
   customerid varchar(10) primary key,
   fullname varchar(30),
   emailaddress varchar(30),
   interests varchar(100)
);

insert into customer values ('A100','John Doe10','Doe10@work.com','Java,Open Source, Computer Graphics');
insert into customer values ('b100','Jane Doe20','Doe20@home.net','Budget Travel, New Zealand, Martial Arts');
  1. Select DB Manager link from the Console Navigation in the left.
  2. Give the database name as CustomerDB and click Create button.
  3. Select CustomerDB to the Use DB field.
  4. Open CustomerService.sql in the CustomerService directory from a text editor.
  5. Paste the content CustomerService.sql to the SQL Commands text area and press Run SQL button.

...

To test the sample web application open and browse and type http://localhost:8080/serviceImage Removed. It will forward you to the index page of the application which has a direct link to view the Customers.