Jetty and JBoss EJB3
JBoss have released with an alpha version of an embeddable EJB3 implementation. It is available for download
Here are the steps required to get jboss-EJB-3.0_Embeddable_ALPHA_5 working with Jetty:
- make sure you're using jre 1.5
- download jboss-EJB-3.0_Embeddable_ALPHA_5.zip and unzip it
- go to the
docs/embedded-tutorial/embedded-wardirectory and build it (just typeant). - unjar the war file in
docs/embedded-tutorial/embedded-war/build/standalone.warto your$jetty.home/webappsdirectory. - move all of the jars in
$jetty.home/webapps/standalone/WEB-INF/libexcept for tutorial.jar to$jetty.home/lib/ext/jbossNote 1 - finally, edit the
$jetty.home/webapps/standalone/EmbeddedEJB3.jspfile. 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:
change them to:Code Block java CustomerDAOLocal local = (CustomerDAOLocal)ctx.lookup(CustomerDAOLocal.class.getName()); CustomerDAORemote remote = (CustomerDAORemote)ctx.lookup(CustomerDAORemote.class.getName());
Code Block java CustomerDAOLocal local = (CustomerDAOLocal)ctx.lookup("CustomerDAOBean/local"); CustomerDAORemote remote = (CustomerDAORemote)ctx.lookup("CustomerDAOBean/remote"); - start jetty:
Code Block java -jar start.jar
- surf to
http://localhost:8080/standalone/EmbeddedEJB3.jspto test EJB3s in Jetty with the JBoss supplied demo
Note 1: Besides being a good idea to move the jboss jars out of the webapp if you intend on using them with other webapps, it seems to be necessary (at least for now) to avoid a strange ClassNotFound exception.