J2EE Deployment Concepts

Overview

This chapter is an overview of several key concepts for assembling and deploying J2EE apps. In , we use Ant to create Java ARchive (JAR) files, Web ARchive (WAR) files, and Enterprise JavaBean (EJB) JARs, so you will need to have a background in the various deployment descriptors for these modules. If you already have considerable experience with J2EE apps, you may want to skip to , The J2EE platform provides component models for assembling apps. J2EE lets you "divide and conquer" an app by buying and building components and wiring them together into an app. Java and J2EE support the following components:

Each component executes in a container. To interoperate with various containers, these components require deployment descriptor files, configuration files, property files, and/or metadata files, and other configuration files. All these files describe the components and how they will interact with other components and their container environment. Deployment can be a complex matter. A typical deployment might involve creating an Enterprise ARchive (EAR) file that can contain JAR and WAR files. The JAR files can in turn contain enterprise beans. The WAR file can in turn contain Web components (servlets, TagLibs, JavaBeans, and JSP), HTML pages, images, Java class files, and other JAR files that contain app components (JavaBeans, client-side remote references to enterprise beans and applets). The deployment descriptor for a Web app (which we will cover later) may contain env-entry elements that are mapped to the Java Naming and Directory Interface (JNDI) names java:comp/env (the context), ejb-ref (describes enterprise beans), and resources-ref (maps Java Messaging Service, Java Database Connectivity, and mail resources so that the Web app can use them). The next two figures show the block diagrams of the two J2EE apps that we build, test, and deploy throughout this tutorial (see , for details on these apps). The first figure shows our HelloWorld app, and the second shows the pet store app. As you can see, several different types of components need to be deployed to multiple servers and containers.

To say that configuration management of a typical J2EE enterprise app is complex is an understatement. In and we will use Ant to help facilitate this process. Otherwise, continuous integration would be pretty tough with the complexities of the J2EE deployment environment.

The remainder of this chapter describes the basic J2EE components and how they are deployed. We also explain the JAR file format, because many components and sets of components are packaged in either a JAR file or some variation of a JAR file.