Table of Contents

Java - Deployment descriptors (Metadata)

About

Deployment descriptors are XML documents included in the JARs that describes:

An enterprise bean module deployment descriptor, for example, declares transaction attributes and security authorizations for an enterprise bean.

Because deployment descriptor information is declarative, it can be changed without modifying the source code. At run time, the J2EE server reads the deployment descriptor and acts upon the component accordingly.

Most J2EE vendors (Application server) provide a GUI tool for generating deployment descriptors and performing deployment because creating manual entries is tedious and error prone.

Type

The two types of deployment descriptors are:

J2EE

A Java EE deployment descriptor is defined by a Java EE specification and can be used to configure deployment settings on any Java EE-compliant implementation.

Runtime

A runtime deployment descriptor is used to configure Java EE implementation-specific parameters.

For example, the GlassFish Server runtime deployment descriptor contains such information as the context root of a web application, as well as GlassFish Server implementation-specific parameters, such as caching directives. The GlassFish Server runtime deployment descriptors are named sun-moduleType.xml and are located in the same META-INF directory as the Java EE deployment descriptor.

Deployment descriptor for

EJB

The following summarizes the new functionality and simplifications made in EJB 3.0 to the earlier EJB APIs:

This reduces the amount of code in your bean file in the case where you are programming a typical EJB; you only need to use additional annotations if the default values do not suit your needs.

The deployment descriptor resides in the META-INF directory inside the EJB JAR file. A JAR can contain multiple beans.

ejb-jar.xml

The standard Java EE deployment descriptor. The ejb-jar.xml may be used to define EJBs and to specify standard configuration settings for the EJBs. An ejb-jar.xml can specify multiple beans that will be deployed together.

weblogic-ejb-jar.xml

WebLogic Server-specific deployment descriptor that contains elements related to WebLogic Server features such as clustering, caching, and transactions. This file is required if your beans take advantage of WebLogic Server-specific features. Like ejb-jar.xml, weblogic-ejb-jar.xml can specify multiple beans that will be deployed together.

weblogic-cmp-jar.xml

WebLogic Server-specific deployment descriptor that contains elements related to container-managed persistence for entity beans.

WAR

In J2EE, a WAR file is typically contained within an EAR file. In the example in the preceding section, the EAR file, J2EEAppName.ear, would have its /META-INF directory at the top level, along with Web module WAR files, EJB module JAR files, client application JAR files, and resource adapter RAR files (zero or more of each, as applicable):

META-INF/
   application.xml
   orion-application.xml (optional)
EJBModuleName.jar
WebModuleName.war
ClientModuleName.jar
ResourceAdapterModuleName.rar 

The following examples show the structure of the archive files for a simple Web application. The EAR file contains a WAR file, which contains a single servlet.