- EAR (file format)
An Enterprise ARchive, or EAR, is a file format used by
Java EE for packaging one or more modules into a single archive so that the deployment of the various modules onto anapplication server happens simultaneously and coherently. It also containsXML files called "deployment descriptors" which describe how to deploy the modules. Maven or Ant can be used to build EAR files.File Structure
An EAR file is a standard JAR file with an .ear extension, with one or more entries representing the modules of the application, and a metadata directory called
META-INF
which contains one or more deployment descriptors.Modules
Different artifacts can be embedded within an EAR file, artifacts which are deployed by the application server:
* A Web module has a
.war extension. It is a deployable unit that consists of one or moreweb component s, other resources, and aweb application deployment descriptor. The web module is contained in ahierarchy of directories and files in a standard web application format.
*POJO Java classes may be deployed in.jar files.
* AnEnterprise Java Bean module has a.jar extension, and contains in its own META-INF directory descriptors describing the persistent classes deployed. When deployed, entity beans are visible to other components and (if remotely exported), remote clients. Message Beans andSession Beans are available for remote access.
* AResource Adapter module has a .rar extensionVendors may support extra artifacts, with their own extensions.Class isolation
Most application servers load classes from a deployed EAR file as an isolated tree of java
classloader s, isolating the application from other applications, but sharing classes between deployed modules. For example, a deployed WAR file would be able to create instances of classes defined in a JAR file that was also included in the containing EAR file, but not necessarily those in JAR files in other EAR files. One key reason for this behaviour is to allow complete separation between applications which use static singletons (e.g. Log4J), which would otherwise mess-up the configuration between separate applications. This also enables different versions of applications and libraries to be deployed side-by-side.The JBoss application server is notable in that it does not isolate deployed components. A web application deployed in one EAR file would have access to classes in other EAR and WAR files. This is a somewhat controversial policy. The "Unified Classloader" design reduces communications overhead between running applications, as class data can be shared by reference or simple copies. It also allows developers to avoid having to understand the problems that a tree of classloaders can create. However, it prevents different versions of dependent libraries from being deployed in separate applications. JBoss 4.0.2 switched to a hierarchical classloader, but as of version 4.0.3, it has reverted to a Unified Classloader for backwards compatibility reasons. There is now a configuration option to change this behavior.
META-INF directory
The
META-INF
directory contains at least theapplication.xml
deployment descriptor, known as the "J2EE Deployment Descriptor". It contains the following XML entities:*
icon
, which specifies the locations for the images that represent the application. A subdivision is made forsmall-icon
andlarge-icon
.
*display-name
, which identifies the application
*description
* Amodule
element for each module in the archive
* Zero or moresecurity-role
elements for the global security roles in the applicationEach
module
element contains anejb
,web
orjava
element which describes the individual modules within the application.Web module s also provide acontext-root
which identifies the web module by its URL.Next to the J2EE deployment descriptor one can have zero or more "runtime deployment descriptors". These are used to configure implementation-specific J2EE parameters.
See also
*
WAR (Sun file format)
*JAR (file format)
*JAR hell Resources
* http://java.sun.com/j2ee/1.4/docs/glossary.html
* http://searchsoa.techtarget.com/expert/KnowledgebaseAnswer/0,289625,sid26_gci837938,00.html
* [http://www.jsptube.com/ Servlet tutorial]
Wikimedia Foundation. 2010.