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

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 ...

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