Jetty has moved!
Jetty is a project at the Eclipse Foundation.
Homepage:http://www.eclipse.org/jetty
Downloads: http://download.eclipse.org/jetty/
Documentation:http://www.eclipse.org/jetty/documentation/current/
About:http://www.eclipse.org/jetty/about.php
Jetty Powered:http://www.eclipse.org/jetty/powered/
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery
Skip to end of metadata
Go to start of metadata

Jetty and Spring EJB3 (Pitchfork)

Pitchfork is an add-on for the Spring Framework performing JSR-250 dependency injection, annotation processing and EJB 3.0-style interception, developed jointly by Interface21 and BEA Systems.

It is simple to use in conjunction with Jetty.

At the time of writing, the integration with Pitchfork is checked in to jetty svn trunk, but will be released with 6.1.0 final. Until then, it will be first necessary to checkout and build jetty.

Once jetty is built, make a new directory: $jetty.home/lib/ext/spring. Copy the jar from $jetty.home/extras/spring/target into it. Also copy all of the jars from the Pitchfork download into it.

Developing a webapp using EJB3

The JEE tutorial from Sun will take you through how to create EJB3 classes.

Here's an extremely simple example of a stateless session bean showing some of the JEE-style annotations:

We would declare this class in a META-INF/spring-ejb-jar.xml file. That file can reside in a jar if you're packaging your ejbs into jars, or you can make a WEB-INF/classes/META-INF/ directory if your ejbs are just part of your webapp.

The spring-ejb-jar.xml file for the above bean looks like:

Next, you can make some classes that use @EJB notation to inject references to your beans. Here's another stupidly simple class that uses the com.acme.EchoBean ejb:

In order to have Pitchfork notice that the com.acme.EchoTest class wants a reference to the com.acme.EchoBean ejb, we declare it in the Spring WEB-INF/applicationContext.xml file:

Notice the very important second line with id jeeEjbPostProcessor. This line tells Pitchfork to look at all other <bean> declarations and perform any necessary resource injections on them.

To complete the webapp, here's a trivial jsp:

When you deploy it and surf to it, you'll see something like this:

Echo EJB

Hello Thu Dec 07 12:14:16 CET 2006

A maven project that builds a deployble webapp for the example we've been looking at is attached to this page.

  • No labels
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery