Enterprise apps and the EAR File

Once you create all your components, you may want to deploy them as a single logical unit called an enterprise app. Doing so will ease the deployment and help ensure that the environment of the staging server is the same or at least as close as possible to the one on the production server. An enterprise app can be contained in single JAR file with the extension .ear, called an enterprise archive (EAR) file. The EAR file contains many JAR files, EJB JAR files, and WAR files called modules. Following is an example of a deployment descriptor for an EAR file:

<app>
 <display-name>Hello World app</display-name>
 <description>Hello World app.</description>
 <module>
 <web>
 <web-uri>hello.war</web-uri>
 <context-root>helloworld</context-root>
 </web>
 </module>
 <module>
 <ejb>greet-ejbs.jar</ejb>
 </module>
</app>

This deployment descriptor would correspond to the following directory structure of an EAR file:

Enterprise Archive file root
| greet-ejbs.jar
| hello.war
|
\---META-INF
 app.xml

This is based on a real example that is presented in . To find out more about EAR files and EAR deployment descriptors, refer to the J2EE Specification chapters "app Assembly" and "Deployment."