In Chapter 11, you learned a bit about how JAX-RS fits in the grander scheme of things like Java EE and Spring. In this chapter, there are two similar examples that define the services illustrated in Chapter 2. The first marries JAX-RS with EJB. The second uses the Spring form to write our JAX-RS services. Instead of using in-memory maps like the earlier examples in the workbook, both examples use Java Persistence (JPA) to map Java objects to a relational database.
Example ex11_1: EJB and JAX-RS
This example shows how you can use JAX-RS with EJB and JPA. It makes use of some of the integration code discussed in Chapter 11.
To implement ex11_1, the JBoss 5.1 Application Server is used to deploy the example. JBoss 5.1 is only Java EE 5–compliant, so it is not JAX-RS-aware. Also, because JBoss 5.1 is not a Java EE 6 implementation, I had to create three different Maven modules to comply with the Java EE 5 packaging structure. The directory structure is shown in Figure 24-1.
The main Maven module of the project is ejb/. Within this directory is a Maven JAR project. It contains the majority of the Java source code of the example. The JAXB, JPA, and EJB classes are all defined in this project along with the JPA deployment descriptor.
The next Maven module of the project is war/. This project configures RESTEasy ...