Introduction
There are a two styles of integrating OpenEJB and Tomcat.
- Single OpenEJB – One instance of OpenEJB inside Tomcat and shared by all webapps.
- Multiple OpenEJB – Multiple instances of OpenEJB inside Tomcat, specifically one OpenEJB instance per webapp.
You cannot mix both styles.
Single OpenEJB style
Also referred to as a "Global" Tomcat and OpenEJB integration.
- Version: OpenEJB 0.9.x or higher, Tomcat 4.x or higher
- Scope: Deployed EJBs are visible to all webapps
- Packaging: EJBs are packaged traditionally and deployed into OpenEJB.
- WEB-INF/lib: Do not put the home or remote interfaces or any ejb related classes in WEB-INF/classes or WEB-INF/lib
- ClassLoader: OpenEJB and EJB's will be loaded into Tomcat's Common ClassLoader
See this page for setup instructions.
Multiple OpenEJB style
Also refered to as Collapsed EAR style as the war file and ejb jar file are merged into one archive.
- Version: OpenEJB 1.x or higher, Tomcat 4.x or higher
- Scope: Deployed EJBs are not visible outside the webapp
- Packaging: EJBs are packaged in the web archive (war).
- WEB-INF/lib: Do put all ejb related classes in (the home, remote interfaces, bean class, etc.) in WEB-INF/classes or WEB-INF/lib
- ClassLoader: OpenEJB and EJB's will be loaded into a Tomcat WebApp ClassLoader (Tomcat has one for each webapp)
See this page for setup instructions.
See also:
- Collapsed EAR on Linux quickstart with setup commands
- Info on Collapsed EARs.
- Online demo of a Collapsed EAR
JNDI
How to configure java:comp/env lookups to lookup ejbs:
- The Short version
- The Detailed version
Security
Unfortunately at this time no security integration with Tomcat/OpenEJB 1.x exists.
Misc
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, feel very welcome to click the 'Edit' link in the upper right and make changes and add new HOWTO's and other docs.