Having had a couple of emails on the Jetty lists about using EJB3 with Jetty, I’ve been looking at the various embeddable technologies around.

Last week I looked at the JBoss Embeddable EJB3 product and got it working in Jetty.

I briefly also mentioned some work we’re doing with the EasyBeans guys – a blog entry is coming on that soon.

A couple of people have mentioned Pitchfork to me in the space of a week, so I decided I’d better check it out. Turns out that it is a an EJB3 implementation for deployment with Spring. There’s an InfoQ article on it, describing it as the result of collaboration between Spring committers and some of the BEA Weblogic team.

Having checked out Christian Dupuis’s blog about using it with Tomcat, I decided to see how hard it would be to use it with Jetty.

The answer was that it was easy!

I’ve added a couple of simple Spring classes to the extras/spring module in Jetty to hook up a webapp to Pitchfork’s resource and ejb injection facilities.

They’re checked in to jetty svn trunk at the moment, so you’ll need to checkout and build jetty to get them. Then:

  1. make a new directory $jetty.home/lib/ext/spring, and copy the $jetty.home/extras/spring/target/jetty-spring-6.1-SNAPSHOT.jar into it
  2. download Pitchfork and copy all of the dist/ and lib/ jars into $jetty.home/lib/ext/spring

Now you can create yourself a webapp, some ejbs and some beans that reference the ejbs using @EJB injection notation, and deploy it to Jetty!

I’ve put more detailed instructions on the Jetty wiki, plus a very simple webapp that uses EJB3s as an example to get you started.