In Chapter 14, 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 Spring to write our JAX-RS services. Instead of using in-memory maps like the earlier examples in the workbook, both examples use the Java Persistence API (JPA) to map Java objects to a relational database.
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 14.
To implement ex14_1, the Wildfly 8.0 Application Server is used to deploy the example. Wildfly is the community version of the JBoss application server. It is Java EE 7–compliant, so JAX-RS 2.0 is already built in. As a result, our Maven pom.xml file needs to change a little to support this example. First, let’s look at the dependency changes in this build file:
Because JAX-RS 2.0 is built in, we do not have to add all the RESTEasy third-party dependencies to our WAR file. The
provided scope is used to tell Maven that the JAR dependencies are needed only for compilation and to not include them within the WAR.
Next, we need to include a ...