You are previewing RESTful Java with JAX-RS.

RESTful Java with JAX-RS

Cover of RESTful Java with JAX-RS by Bill Burke Published by O'Reilly Media, Inc.
O'Reilly logo

Example ex11_2: Spring and JAX-RS

There isn’t much difference between the code of ex11_1 and ex11_2. The Java classes are basically the same, except the @Stateless annotations were removed from the JAX-RS resource classes because the example is using Spring instead of EJB for its component model. For the same reason, the EJBExceptionMapper class isn’t needed anymore.

Besides the removal of EJB metadata, the differences between the two projects are mainly packaging and configuration. If you look through the ex11_2 directory, you’ll see that we’re back to using embedded Jetty and a single WAR project. The web.xml file is a bit different than the EJB example, so let’s take a look at that first:





This example follows the Spring integration conventions discussed in Chapter 11. The web.xml file adds an <env-entry> to point to the Spring XML file that holds all of the example’s Spring configuration. Let’s look at this Spring XML file:


<beans xmlns="" xmlns:xsi="" xmlns:tx="" xsi:schemaLocation=" ...

The best content for your career. Discover unlimited learning on demand for around $1/day.