Chapter 11. Deployment and Integration

Throughout this book, I have focused on teaching you the basics of JAX-RS and REST with simple examples that have very few moving parts. In the real world, though, your JAX-RS services are going to interact with databases and a variety of server-side component models. They will need to be secure and sometimes transactional. Also, except for Chapter 3, I pretty much ignored how to assemble JAX-RS-based services in complex environments like Java EE. In this chapter, we’ll look into deployment details of JAX-RS and how it integrates with Java EE and other component models.

Deployment

JAX-RS applications are deployed within a servlet container, like Apache Tomcat, Jetty, JBossWeb, or the servlet container of your favorite application server, like JBoss, Weblogic, Websphere, or Glassfish. Think of a servlet container as a web server. It understands the HTTP protocol and provides a low-level component model (the servlet API) for receiving HTTP requests.

Servlet-based applications are organized in deployment units called Web ARchives (WAR). A WAR is a JAR-based packaging format that contains the Java classes and libraries used by the deployment as well as static content like images and HTML files that the web server will publish. Here’s what the structure of a WAR file looks like:

<any static content>
WEB-INF/
        web.xml
        classes/
        lib/

Any files outside and above the WEB-INF/ directory of the archive are published and available directly through HTTP. This ...

Get RESTful Java with JAX-RS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.