[ f a q ]     [ w i k i ]     [ l i s t s ]     [ c v s ]     [ b u g s ]     
 

Main
    Welcome!
    Download
    Mailing Lists
    Source Code
    The Team
    Status
Users
    Quickstart
    Hello World!
    CMP Example
    CMP Guide
    Deploy
    Startup
    Validation
    Configuration
    Properties
Servers
    Local Server
    Remote Server
    Tomcat
    Geronimo
Integrators
    Why OpenEJB
    Overview
    Design
    Presentation


The Codehaus
  



OpenEJB Tomcat Integration


Introduction
OpenEJB per Tomcat instance
OpenEJB per webapp
OpenEJB Tomcat resource factory
How to make the document even more helpful resource

Introduction

There are a few approaches to integrate OpenEJB and Jakarta Tomcat. The difference between them is in the visibility of EJBs (deployed onto OpenEJB) amongst web applications (deployed onto Tomcat). The term visibility means what classloaders handle loading of the EJBs.
OpenEJB configuration by its visibility
OpenEJB per Tomcat instance - deployed EJBs are shared amongst all of the web apps
OpenEJB per webapp - deployed EJBs are visible only to the web apps that declared to load OpenEJB
OpenEJB Tomcat resource factory - an implementation of Tomcat's resource factory mechanism

OpenEJB per Tomcat instance

Configure OpenEJB per Tomcat instance requires the following steps:

  1. Copy the war/openejb-loader-1.0-SNAPSHOT.war into the webapps dir of a running Tomcat install
  2. Under Unix
    $ cd $OPENEJB_HOME
    $ cp war/openejb-loader-1.0-SNAPSHOT.war $CATALINA_HOME/webapps
    
    or
    Under Windows
    c:/> cd %OPENEJB_HOME%
    %OPENEJB_HOME%> cp war/openejb-loader-1.0-SNAPSHOT.war %CATALINA_HOME%/webapps
    
  3. Update the openejb.home init param (inside the WEB-INF/web.xml file) to point to where OpenEJB was installed.
    If OpenEJB has been built from the source you can skip it (during the build procedure it is updated automatically)
  4. Under Unix
    $ cd $CATALINA_HOME/webapps
    $ jar -xvf openejb-loader-1.0-SNAPSHOT.war WEB-INF/web.xml
    ...edit WEB-INF/web.xml...
    $ jar -uvf openejb-loader-1.0-SNAPSHOT.war WEB-INF/web.xml
    $ rm -rf WEB-INF
    
    or
    Under Windows
    c:/> cd %CATALINA_HOME%/webapps
    %CATALINA_HOME%/webapps> jar -xvf openejb-loader-1.0-SNAPSHOT.war WEB-INF/web.xml
    ...edit WEB-INF/web.xml...
    %CATALINA_HOME%/webapps> jar -uvf openejb-loader-1.0-SNAPSHOT.war WEB-INF/web.xml
    %CATALINA_HOME%/webapps> rmdir /S /Q WEB-INF
    
  5. Create the temp directory under Tomcat's home directory
  6.  NOTE
    This is because the beans that's been successfully validated are deployed. During validation OpenEJB creates temporary files under the temp.dir directory, which is overriden by Tomcat to its temp directory. Unfortunatelly, the directory doesn't exist and needs to be created manually.
  7. Deploy your webapps that are using the beans deployed onto OpenEJB
  8. Start up Tomcat and have fun with the EJBs

OpenEJB per webapp

Configure OpenEJB per webapp requires the following steps:

  1. Copy the openejb-loader-*.jar into the WEB-INF/lib directory of the webapp that is to use EJBs deployed onto OpenEJB
  2. Add the loader servlet definition to the WEB-INF/web.xml file of the webapp with a valid value for openejb.home init-param.
    
      <servlet>
        <servlet-name>loader</servlet-name>
        <servlet-class>org.openejb.loader.LoaderServlet</servlet-class>
        <init-param>
          <param-name>openejb.loader</param-name>
          <param-value>tomcat-webapp</param-value>
        </init-param>
        <init-param>
          <param-name>openejb.home</param-name>
          <param-value>...define OPENEJB_HOME here...</param-value>
        </init-param>
        <load-on-startup>0</load-on-startup>
      </servlet>
    
    

    Should you define other OpenEJB configuration settings use another <init-param> stanza. It's just for that. These parameters are directly passed to OpenEJB at initialization of the servlet. Think about the loader servlet as a bridge between OpenEJB's world (EJBs) and Tomcat's world (servlets, JSPs).

    At startup OpenEJB prints out all of the configuration settings to Tomcat logs:

    INFO: Installing web application at context path /openejb from URL file:C:\webapps\openejb
    OpenEJB init-params:
            param-name: openejb.home, param-value: c:\openejb
            param-name: openejb.configuration, param-value: conf\openejb.cfg
            param-name: openejb.base, param-value: c:\webapps\openejb\WEB-INF\openejb
            param-name: openejb.loader, param-value: tomcat-webapp
  3. Start up Tomcat and have fun with the EJBs

OpenEJB Tomcat resource factory

Read about it here.

How to make the document even more helpful resource

This document is a starting point for using OpenEJB in Tomcat and will evolve based on user contributions. If you wish to contribute to this document, please email the text to the OpenEJB User list.
How does the integration work
Where to put your ejb classes
How to configure java:comp/env lookups (short)
How to configure java:comp/env lookups (detailed)

Misc:
Basic info
Servlets FAQ


 
     
   
   
 


OpenEJB is a trademark of the OpenEJB Group. Java, EJB, JDBC, JNDI, JTA, Sun, Sun Microsystems are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and in other countries. XML, XML Schema, XSLT and related standards are trademarks or registered trademarks of MIT, INRIA, Keio or others, and a product of the World Wide Web Consortium. All other product names mentioned herein are trademarks of their respective owners.