Chapter 3. Building and Deploying an EAR
In the last chapter we introduced you to web applications, but the web tier is just one part of the J2EE spectrum. In this chapter, weâll expand the JAW application from a simple WAR file into a full-fledged EAR.
Weâll explore the different parts of an EAR file. Weâll build a Common JAR containing classes that can be shared across all tiers of the application. Finally, weâll play with various Ant and XDoclet tasks to create our EAR and dynamically generate the deployment descriptors JBoss needs.
WARs Versus EARs
The WAR file is a convenient way to bundle up all pieces of a web application. All servlet containers know how to deploy a WAR fileâthey expand the bundle, look for the WEB-INF directory, and read the web.xml found there for further deployment instructions.
The EAR file provides the same type of functionality for a full-fledged J2EE application. JBoss expands the EAR, finds the required deployment descriptors, and proceeds from there.
An EAR is like a carton of eggsâit keeps everything organized. While the carton doesnât add any direct value to your omelet, it makes getting the eggs home from the store so easy that you wouldnât think about transporting eggs any other way.
Each egg in your EAR carton is a specific piece of the J2EE puzzle. These eggs (or JARs) come in three basic varieties called âmodulesâ:
- Web module
A WAR file containing presentation tier components
- EJB module
An EJB JAR file containing the middle-tier ...
Get JBoss at Work: A Practical Guide 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.