JBoss have come up with an embeddable version of their EJB3 implementation. An alpha release is available for download.

I downloaded it and played around with the embedded example from the tutorial.
Here’s what I did:

  1. once you’ve downloaded and unzipped the alpha release (I tested with jboss-EJB-3.0_Embeddable_ALPHA_5.zip), go to the
    docs/embedded-tutorial/embedded-war directory and build it (just type ant).
  2. unjar the war file in docs/embedded-tutorial/embedded-war/build/standalone.war to your $jetty.home/webapps directory.
  3. move all of the jars in $jetty.home/webapps/standalone/WEB-INF/lib except for tutorial.jar to $jetty.home/lib/ext/jboss (see below for more on this).
  4. finally, edit the $jetty.home/webapps/standalone/EmbeddedEJB3.jsp file. The JNDI lookups for the beans in this file don’t work and don’t match the documentation, so you need to change them. Find the lines:

    CustomerDAOLocal local = (CustomerDAOLocal)
    CustomerDAORemote remote = (CustomerDAORemote)

    change them to:

    CustomerDAOLocal local = (CustomerDAOLocal)
    CustomerDAORemote remote = (CustomerDAORemote)

  5. start jetty: java -jar start.jar and now you can test EJB3s in jetty by surfing to the demo: http://localhost:8080/standalone/EmbeddedEJB3.jsp

I don’t think it should be necessary to move the jboss jars out of the webapp, but it makes sense if you want to use EJB3 with more than one webapp.

I haven’t as yet been able to make it work with leaving the jars inside the webapp. I get a ClassNotFoundException:

Caused by: org.jboss.util.NestedRuntimeException:
Cannot load class org.jboss.mx.server.JBossMXServerConfig;
- nested throwable: (java.lang.ClassNotFoundException:
at org.jboss.util.Classes.instantiate(Classes.java:514)
at org.jboss.mx.server.ServerConfig.getInstance(ServerConfig.java:74)
at javax.management.MBeanServerFactory.(MBeanServerFactory.java:79)

The class doesn’t seem to exist in any of the jars supplied with the demo, so the ClassNotFoundException seems reasonable enough. However, I haven’t had time to investigate why it does not occur when the jars are in Jetty’s lib directory.

Jetty and JBoss EJB3

3 thoughts on “Jetty and JBoss EJB3

  • December 4, 2006 at 3:17 pm

    So much simpler to use Spring’s pitchfork instead. That way you’re not tied to any provider, and can easily switch from one vendor to another for the JPA implementation. No classpath issues either.

  • December 4, 2006 at 7:37 pm


    As you’re the second person in a week to mention pitchfork to me, I’ll have to take the hint and check it out 🙂

    Note that we’ve done some work so that Jetty will also work with Easybeans (http://www.easybeans.org) – support for Jetty is in Easybeans svn trunk at the moment but is scheduled for the next milestone release. I’ll blog about it a little later.


  • April 6, 2007 at 12:01 am

    How would one go about incorporating these jars when executing jetty from the maven plugin ? I tried monkeying about with setting the jetty.class.path system property in the pom with <systemProperty>, to no avail. I still get the infuriating
    java.lang.ClassNotFoundException: org.jboss.mx.server.JBossMXServerConfig
    Any pointers would be greatly appreciated!

Comments are closed.