Configuration for Geronimo

The configuration file that will be generated for Geronimo EAR is called Shark.conf.in and is located in <shark_install_dir>/.dist/EJB/conf directory. During the build of EAR, the parameters specific for Geronimo are set to the following values:

EnvironmentType=geronimo
DatabaseManager.DB.sharkdb.Connection.DataSourceName=jndi:jdbc/sharkBase
DatabaseManager.DB.sharkdb.ObjectId.ClassName=org.enhydra.dods.jta.GeronimoJTAObjectIdAllocator
DatabaseManager.defaults.TransactionFactory=org.enhydra.dods.jta.GeronimoDBTransactionFactory

The parameter DataSourceName has the following form: "jndi:<jndi name of the database defined in Geronimo>". In this example, jndi name is jdbc/sharkBase.

Geronimo needs some additional configuration files. In all files in which the database jndi name is needed, it is set to value "jdbc/sharkBase". The configuration file that defines deployment plan (database) is called sharkdb.xml.in and is located in <shark_install_dir>/.dist/EJB/conf/geronimo directory. In this file should be the database name be set to value sharkdb (because of various settings in all configuration files). During the EAR generation, this file will be generated for the database defined in configure.properties file under the name sharkdb.xml.

The example of sharkdb.xml file that defines Postgresql database:

<?xml version="1.0" encoding="UTF-8"?>
<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.1">
    <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
        <dep:moduleId>
            <dep:groupId>console.dbpool</dep:groupId>
            <dep:artifactId>sharkdb</dep:artifactId>
            <dep:version>1.0</dep:version>
            <dep:type>rar</dep:type>
        </dep:moduleId>
         <dep:dependencies>
            <dep:dependency>
                <dep:groupId>sharkdbdriver</dep:groupId>
                <dep:artifactId>sharkdbdriver</dep:artifactId>
                <dep:version>1.0</dep:version>
                <dep:type>jar</dep:type>
            </dep:dependency>
        </dep:dependencies>
    </dep:environment>
    <resourceadapter>
        <outbound-resourceadapter>
            <connection-definition>
                <connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface>
                <connectiondefinition-instance>
                    <name>sharkdb</name>
                    <config-property-setting name="Driver">org.postgresql.Driver</config-property-setting>
                    <config-property-setting name="UserName">sa</config-property-setting>
                    <config-property-setting name="Password">sa</config-property-setting>
                    <config-property-setting name="ConnectionURL">jdbc:postgresql://localhost/shark</config-property-setting>
                    <connectionmanager>
                        <local-transaction/>
                        <single-pool>
                            <max-size>10</max-size>
                            <min-size>0</min-size>
                            <match-one/>
                        </single-pool>
                    </connectionmanager>
                </connectiondefinition-instance>
            </connection-definition>
        </outbound-resourceadapter>
    </resourceadapter>
</connector>

Also, proper jdbc drivers should be added to geronimo's repository (if not added yet). Jdbc driver should be also set in sharkdb.xml file. To make the story general, the universal name for the database driver is set:

  <dep:dependencies>
            <dep:dependency>
                <dep:groupId>sharkdbdriver</dep:groupId>
                <dep:artifactId>sharkdbdriver</dep:artifactId>
                <dep:version>1.0</dep:version>
                <dep:type>jar</dep:type>
            </dep:dependency>
        </dep:dependencies>

So, jdbc driver should be named sharkdbdriver-1.0.jar and should be placed in <geronimo_root>/repository/sharkdbdriver/sharkdbdriver/1.0 directory. When driver is renamed and placed in repository directory as explained, it should be added to the Common libs list that can be viewed by using Geronimo Admin application. By default, the url is http://localhost:8080/console. Off course, in order to use the console, Apache Geronimo must be running.

By default, username for Apache Geronimo admin is "system", and password is "manager".

When admin application appears, go to Services -> Common Libs, and check if in the list appears desired database drivers.

As mentioned, there are some differences in the number and content of configuration files between Apache Geronimo and other EJB servers. Here are explained additional Apache Geronimo's configuration files.

File application.xml, located in EAR's META-INF directory, contains one additional connector:

<?xml version="1.0" encoding="UTF-8"?>
<application>
  . . .
  <module>
    <connector>tranql-connector-1.2.rar</connector>
  </module>
</application>

File geronimo-application.xml, located in EAR's META-INF directory, is specific for Apache Geronimo and looks like:

<?xml version="1.0" encoding="UTF-8"?>
<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>enhydra</dep:groupId>
   <dep:artifactId>Shark</dep:artifactId>
   <dep:version>1.0</dep:version>
   <dep:type>car</dep:type>
  </dep:moduleId>
  <dep:dependencies/>
  <dep:hidden-classes/>
  <dep:non-overridable-classes/>
 </dep:environment>
 <module>
     <connector>tranql-connector-1.2.rar</connector>
     <alt-dd>sharkdb.xml</alt-dd>
 </module>
</application>

If web.xml file exists in the EAR, in the same location must also exist geronimo-web.xml file.

For example, if web.xml file looks like:

<?xml version="1.0" encoding="ISO-8859-1"?>
. . .
<web-app>
  <display-name>shark-ejb</display-name>
  <description>Shark EJB sample JSP application.</description>
</web-app>

The geronimo-web.xml file can look like:

<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1" xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1">
  <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
    <dep:moduleId>
      <dep:groupId>enhydra</dep:groupId>
      <dep:artifactId>shark</dep:artifactId>
      <dep:version>1.0</dep:version>
      <dep:type>car</dep:type>
    </dep:moduleId>
    <dep:dependencies/>
    <dep:hidden-classes/>
    <dep:non-overridable-classes/>
  </dep:environment>
  <context-root>/shark</context-root> 
</web-app>

File openejb-jar.xml, located in META-INF directory of jar file (sharkejb.jar) that contains shark beans (inside EAR), looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
 <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
  <dep:moduleId>
   <dep:groupId>enhydra</dep:groupId>
   <dep:artifactId>Shark</dep:artifactId>
   <dep:version>1.0</dep:version>
   <dep:type>car</dep:type>
  </dep:moduleId>
  <dep:dependencies/>
  <dep:hidden-classes/>
  <dep:non-overridable-classes/>
 </dep:environment>
 
 <cmp-connection-factory>
  <resource-link>sharkdb</resource-link>
 </cmp-connection-factory>

 <enterprise-beans>
  <session>
   <ejb-name>WAPIEJB</ejb-name>
   <jndi-name>org/enhydra/shark/ejb/WAPIEJB</jndi-name>
   <resource-ref>
    <ref-name>jdbc/sharkBase</ref-name>
    <resource-link>sharkdb</resource-link>
   </resource-ref>
  </session>
  
  . . .
  <session>
  ... defined for every bean ... 
  </session>
  . . .

 </enterprise-beans>
</openejb-jar>

If database in deployment plan (file sharkdb.xml) is set to name jdbc/sharkBase (as explained in this chapter), none of this additional files needn't be changed. Only deployment plan sharkdb.xml, if not set for the proper database in configure.properties file, must be changed manually to the desired values before EAR generation.

File geronimo_client.properties is located in <shark_install_dir>/.dist/EJB/conf/geronimo directory and contains the values needed for JNDI context creation. By default, this file contains geronimo's defaults:

java.naming.factory.initial=org.openejb.client.RemoteInitialContextFactory
java.naming.provider.url=localhost:4201
java.naming.security.principal=system
java.naming.security.credentials=manager