EAR (file format)
Encyclopedia
EAR is a file format
File format
A file format is a particular way that information is encoded for storage in a computer file.Since a disk drive, or indeed any computer storage, can store only bits, the computer must have some way of converting information to 0s and 1s and vice-versa. There are different kinds of formats for...

 used by Java EE for packaging one or more modules into a single archive so that the deployment of the various module
J2EE application
A Java EE application or a Java Platform, Enterprise Edition application is any deployable unit of Java EE functionality. This can be a single Java EE module or a group of modules packaged into an EAR file along with a Java EE application deployment descriptor...

s onto an application server
Application server
An application server is a software framework that provides an environment in which applications can run, no matter what the applications are or what they do...

 happens simultaneously and coherently. It also contains XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....

 files called deployment descriptor
Deployment Descriptor
A deployment descriptor refers to a configuration file for an artifact that is deployed to some container/engine.In the Java Platform, Enterprise Edition, a deployment descriptor describes how a component, module or application should be deployed...

s which describe how to deploy the modules.

Ant
Apache Ant
Apache Ant is a software tool for automating software build processes. It is similar to Make but is implemented using the Java language, requires the Java platform, and is best suited to building Java projects....

 or Maven
Apache Maven
Maven is a build automation and software comprehension tool. While primarily used for Java programming, it can also be used to build and manage projects written in C#, Ruby, Scala, and other languages. Maven serves a similar purpose to the Apache Ant tool, but it is based on different concepts and...

 can be used to build EAR files.

File structure

An EAR file is a standard JAR file
JAR (file format)
In software, JAR is an archive file format typically used to aggregate many Java class files and associated metadata and resources into one file to distribute application software or libraries on the Java platform.JAR files are built on the ZIP file format and have the .jar file extension...

 (and therefore a Zip
ZIP (file format)
Zip is a file format used for data compression and archiving. A zip file contains one or more files that have been compressed, to reduce file size, or stored as is...

 file) with a .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

Developers can embed various artifacts within an EAR file for deployment by application servers:
  • A Web module has a .war extension. It is a deployable unit that consists of one or more web components, other resources, and a web application
    Web application
    A web application is an application that is accessed over a network such as the Internet or an intranet. The term may also mean a computer software application that is coded in a browser-supported language and reliant on a common web browser to render the application executable.Web applications are...

     deployment descriptor. The web module is contained in a hierarchy
    Hierarchy
    A hierarchy is an arrangement of items in which the items are represented as being "above," "below," or "at the same level as" one another...

     of directories and files in a standard web application format.
  • POJO
    Pojo
    Pojo may refer to:* Pohja, the Swedish name for the Finnish municipality* POJO, abbreviation of Plain Old Java Object in computer programming...

     Java classes may be deployed in .jar files.
  • An Enterprise Java Bean module has a .jar extension, and contains in its own META-INF directory descriptors describing the persistent classes deployed. Deployed entity beans become visible to other components and, if remotely exported, to remote clients. Message Beans and Session Beans
    Session Beans
    In the Java Platform, Enterprise Edition specifications, a Session Bean is a type of Enterprise Bean. The only other type is the Message-driven bean. Legacy EJB versions from before 2006 had a third type of bean, the Entity Bean...

     are available for remote access.
  • A Resource Adapter module has a .rar extension.

Class isolation

Most application servers load classes from a deployed EAR file as an isolated tree of Java classloaders, 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 behavior is to allow complete separation between applications which use static singletons (e.g. Log4J), which would otherwise confuse the configuration between separate applications. This also enables different versions of applications and libraries to be deployed side-by-side.

The JBoss
JBoss
JBoss Application Server is an open-source Java EE-based application server. An important distinction for this class of software is that it not only implements a server that runs on Java, but it actually implements the Java EE part of Java...

 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 the application.xml deployment descriptor, known as the Java EE Deployment Descriptor. It contains the following XML entities:
  • icon, which specifies the locations for the images that represent the application. A subdivision is made for small-icon and large-icon.
  • display-name, which identifies the application
  • description
  • A module element for each module in the archive
  • Zero or more security-role elements for the global security roles in the application


Each module element contains an ejb, web or java element which describes the individual modules within the application. Web modules also provide a context-root which identifies the web module by its URL.

Next to the Java EE deployment descriptor there can be zero or more runtime deployment descriptors. These are used to configure implementation-specific Java EE parameters.

See also

  • Enterprise software
    Enterprise software
    Enterprise software, also known as enterprise application software , is software used in organizations, such as in a business or government, contrary to software chosen by individuals...

  • WAR file format (Sun)
  • JAR (file format)
    JAR (file format)
    In software, JAR is an archive file format typically used to aggregate many Java class files and associated metadata and resources into one file to distribute application software or libraries on the Java platform.JAR files are built on the ZIP file format and have the .jar file extension...

  • JAR hell
  • Deployment Descriptor
    Deployment Descriptor
    A deployment descriptor refers to a configuration file for an artifact that is deployed to some container/engine.In the Java Platform, Enterprise Edition, a deployment descriptor describes how a component, module or application should be deployed...


External links

  • http://java.sun.com/j2ee/1.4/docs/glossary.html
  • http://java.sun.com/javaee/5/docs/tutorial/doc/bnaby.html#indexterm-47
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK