Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{warning}
These instructions are out of date and are currently being worked on.  In the mean time, please use the installer servlet.
{warning}


h1. {anchor:install-openejb}Install OpenEJB

Once Tomcat has been installed, the OpenEJB plugin for Tomcat can be installed.  The commands in this example are executed within the Tomcat installation directory.

h2. Unpack OpenEJB Tomcat plugin in Tomcat webapps directory

Change to the webapps directory:

{code:none}apache-tomcat-6.0.14$ cd webapps{code}

Unpack the openejb-tomcat-3.0.0-SNAPSHOT-bin.zip file.

{code:none}apache-tomcat-6.0.14/webapps$ jar -xvf ../openejb-tomcat-3.0.0-SNAPSHOT-bin.zip
  created: openejb/
  created: openejb/WEB-INF/
  created: openejb/lib/
 inflated: openejb/lib/geronimo-javamail_1.4_spec-1.1.jar
 inflated: openejb/lib/xbean-finder-3.1.jar
...snip...
{code}

The OpenEJB directory should contain the following files:

{code:none}apache-tomcat-6.0.14/webapps$ ls openejb
WEB-INF/     lib/         openejb.xml
{code}

Return to the Tomcat install directory 

{code:none}apache-tomcat-6.0.14/webapps$ cd ..{code}

h2. Add the OpenEJB listener to Tomcat 

Tomcat listeners must be available in the Tomcat common class loader, so the openejb-loader jar must be copied into the Tomcat lib directory.

{code:none} apache-tomcat-6.0.14$ cp webapps/openejb/lib/openejb-loader-3.0.0-SNAPSHOT.jar lib/{code}

Add the following {highlight}highlighted lines{highlight} to your conf/server.xml file to load the OpenEJB listener:
 
{panel:title=conf/server.xml}
<!-- Note:  A "Server" is not itself a "Container", so you may not
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;define subcomponents such as "Valves" at this level.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Documentation at /docs/config/server.html
 -->
<Server port="8005" shutdown="SHUTDOWN">
&nbsp;&nbsp;{highlight}<!-- OpenEJB plugin for tomcat -->{highlight}
&nbsp;&nbsp;{highlight}<Listener className="org.apache.openejb.loader.OpenEJBListener" />{highlight}

&nbsp;&nbsp;<!--APR library loader. Documentation at /docs/apr.html -->
&nbsp;&nbsp;<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
...snip...
{panel} 

h2. Delete the Tomcat annotations-api.jar file

Tomcat contains an old non-compliant version of the javax.annotation classes and these invalid classes must be removed so OpenEJB can process annotations.  Simply, rename the annotation-api.jar so it doesn't end with {{".jar"}}.  For example:

{code:none}apache-tomcat-6.0.14$ mv lib/annotations-api.jar lib/annotations-api.jar-INVALID{code}

h2. Add OpenEJB javaagent to Tomcat startup

OpenJPA, the Java Persistence implementation used by OpenEJB, currently must enhanced persistence classes to function properly, and this requires the installation of a javaagent into the Tomcat startup process.

Simply, add the following {highlight}highlighted lines{highlight} to the bin/catalina.sh file to enable the OpenEJB javaagent:

{panel:title=bin/catalina.sh}
...snip...
\# Set juli LogManager if it is present
if [ -r "$CATALINA_BASE"/conf/logging.properties ]; then
&nbsp;&nbsp;JAVA_OPTS="$JAVA_OPTS "-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" "-Djava.util.logging.config.file="$CATALINA_BASE/conf/logging.properties"
fi

{highlight}\# Add OpenEJB javaagent
if [ -r "$CATALINA_BASE"/webapps/openejb/lib/openejb-javaagent-3.0.0-SNAPSHOT.jar ]; then
&nbsp;&nbsp;JAVA_OPTS=""-javaagent:$CATALINA_BASE/webapps/openejb/lib/openejb-javaagent-3.0.0-SNAPSHOT.jar" $JAVA_OPTS"
fi{highlight}

\# ----- Execute The Requested Command -----------------------------------------

\# Bugzilla 37848: only output this if we have a TTY
if [ $have_tty -eq 1 ]; then
&nbsp;&nbsp;echo "Using CATALINA_BASE:   $CATALINA_BASE"
...snip...
{panel} 

*NOTE:* The example above is an excerpt from the middle of the bin/catalina.sh file.  Search for "Execute" in the file to locate the correct position in the file to add the new lines.

...