One of the requirements for every J2EE application module is that it must include an XML-based deployment descriptor. The location differs for each module type, but the overall construction is similar.
Table 10.1. J2EE Deployment Descriptor File Names
Module Type | Deployment Descriptor File |
---|---|
Web Application | WEB-INF/web.xml |
EJB JAR | META-INF/ejb-jar.xml |
J2EE Connector | META-INF/ra.xml |
Client Application | META-INF/application-client.xml |
Enterprise Application | META-INF/application.xml |
Note | |
---|---|
For application modules packaged in an EAR, the deployment descriptors for each module in the ear may be stored in the EAR but outside the module archives, by using the alt-dd element when each module is described in the application.xml deployment descriptor for the EAR. |
In J2EE specifications up through version 1.3, these deployment descriptors were based on XML DTDs. Starting with J2EE 1.4, these deployment descriptors are based on XML Schemas. In general, there is little difference from the perspective of a developer -- either a schema or a DTD indicates which elements are allowed to go where in the deployment descriptor, and what they might contain. However, the file headers are slightly different, as the way an XML file indicates that it complies with a schema is different than the way it would indicate that it complied with a DTD:
Example 10.1. Deployment Descriptors: Schema vs. DTD Headers
A DTD-based deployment descriptor for a v2.3 web application might look like this:
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app>
The same deployment descriptor for a v2.4 web application would look like this:
<?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
Both header styles include some sort of unique identifier, and the DTD-based header refers to a DTD (.dtd file) while the Schema-based header refers to a Schema (.xsd file). One subtlety is that on the Schema side, most of the J2EE schemas use the same namespace (http://java.sun.com/xml/ns/j2ee), even though they use different schema files. The key here is that all the J2EE schema files are part of the same namespace, but there are separate entry points for each deployment descriptor. The web deployment descriptor uses only web and common elements, while the EJB deployment descriptor uses only EJB and common elements, etc.
Geronimo includes a current version of all the J2EE schema files in the schema/ subdirectory of the Geronimo installation. The most current revisions of the schemas from Sun are available at http://java.sun.com/xml/ns/j2ee/.
Tip | |
---|---|
Geronimo services, as opposed to application modules, do not require a J2EE deployment descriptor. |