2.3. Application Assemblies
Once we have our components assembled into the appropriate modules, each with a deployment descriptor, we can assemble an application by bundling the component modules along with an application deployment descriptor into an enterprise application archive (ear) file.
Like component modules, an application archive is just a jar file with files stored in specific locations, as dictated by the J2EE specifications. The deployment descriptor is stored as META-INF/application.xml in the jar file, and component modules are placed in the jar and referenced in the application descriptor using their location relative to the top of the application archive. The full syntax of the application deployment descriptors can be found in Appendix A.
Application deployment descriptors are simpler in structure, because they primarily serve to assemble component modules that have their own deployment information. The application deployment descriptor contains the following categories of information:
2.3.1. Application Assembly Example
Returning to our example application, we now need to create an application archive containing our application's two component module archives. One module is an EJB module that contains the profile EJB component, and the other is a web module that contains the UI elements, including the JSP used for viewing profiles.
Figure 2-6 shows our application deployment descriptor. The first section of the file contains some descriptive information about the application as a whole. Following this, we declare the two module archives that contain our components. These jar files must be found in the application archive when the application is deployed at the relative locations used here in the <module> elements. Finally, our example descriptor declares some security roles to potentially be used by the application at runtime. As with any roles declared at the component level, the application server should verify that these roles have been configured within its runtime environment when the application is deployed.
Figure 2-6. Application deployment descriptor