Discussions

General J2EE: EJBs from Tomcat, without fuss

  1. EJBs from Tomcat, without fuss (2 messages)

    Hey All,

    There is a great article at O'Reilly about using EJBs from Tomcat.
    http://www.onjava.com/pub/a/onjava/2003/02/12/ejb_tomcat.html

    Should be particularly useful to anyone already using Tomcat who would like to try out the whole EJB thing with little fuss.

    Enjoy!

    -David

    Threaded Messages (2)

  2. EJBs from Tomcat, without fuss[ Go to top ]

    Isn't this really EJB's with OpenEJB. I'm not sure how different with is compared to JBoss with Tomcat. I'm not trying to negate your experience, but just wanted to mention to others.

    Chuck
  3. EJBs from Tomcat, without fuss[ Go to top ]

    There are some neat things about this integration. First, it's really loosely coupled, much like plugging in a JDBC driver. It would seem ridiculous to have to use a Tomcat-JDBC bundle created by a JDBC driver vendor just to get at a database. OpenEJB plugs into Tomcat just like a driver is, so you can use whatever version of Tomcat you like.

    Also, since it's loosely coupled, you can plug it into and existing setup and try it out. If you like it, use it, if you don't, just un-plug it. No need to move webapps back and forth between servers -- no need to monkey with your webapps or setup at all.

    OpenEJB runs in the same VM as Tomcat giving you a locally optimized Servlet/JSP/EJB environment. Plus, OpenEJB has a feature to shut of the marshalling of calls to ejbs through the Remote interfaces, essentially treating them as EJB 2.0 local interfaces. So, you can run your Servlet's and EJBs together *completely* locally, but then later switch the EJBs to a second server if you need to, with no code changes required. No need to edit your servlets to use the remote interfaces rather than the local interfaces.

    On other notes, you can also use OpenEJB locally from plain old java applications. You just put the openejb_loader.jar in your classpath and it will load all the EJB container into your VM the first time you instantiate an InitialContext that points to the org.openejb.client.LocalInitialContext provider.

    This would allow you to use things like EntityBeans in a completely optimized local environment in place of something like JDO. The advantage is that you have the flexibility to breakup your application as it grows and you decide to host some or all of the EJBs on another machine. OpenEJB uses Castor JDO as the persistence mechanism and just has a thin container level over the top. Essentially, using OpenEJB for persistence is JDO with growth potential. I find that to be an interesting compromise as people debate whether or not to use something like JDO or EJBs. With OpenEJB you get both at the same time and have the flexibility to grow your applications architecture with no code change.