Rintoul
Rintoul

Reputation: 833

Application Deployment Descriptor in Java EE 6

I would like to set the context-root of the web application part of my enterprise application (bundled as an EAR). I added an "application.xml" file which looks like this:

<application>
    <module>
        <web>
            <web-uri>SearchResulter-war.war</web-uri>
            <context-root>/searcharoo</context-root>
        </web>
    </module>
</application>

The thing is, I have EJBs in the project as well. It seems that the Java EE 5/6 magic previously did not require me to include an "application.xml" file, and that was all good until I wanted to change the context-root. Is it an all-or-nothing proposition as far as defining your own goes? In other words, must I add an <ejb> element with the relevant info?

Upvotes: 0

Views: 4672

Answers (4)

BJYC
BJYC

Reputation: 384

First of all, you don't have to use application.xml. Since you have a war file, you can use the container specific deployment descriptor to define the context-root. For example, in WebLogic Server Administration Console doc, it reads,

"You can specify the context-root element in the weblogic.xml deployment descriptor for Web Applications that are packaged as a .war archive or exploded .war directory. If you package the Web Application as part of an Enterprise Application (.ear archive or exploded .ear), specify the context-root in application.xml. Note that the application.xml context-root takes precedent over the weblogic.xml value."

Or, in glassfish-web.xml (or sun-web.xml) for the case of Glassfish.

If you do decide to use the standard application.xml, the container would pick up the full list of modules from this descriptor. In other word, application.xml takes precedent over module-level descriptors. So yes, you would need to also include your ejb elements in your application.xml.

Upvotes: 1

Pascal Thivent
Pascal Thivent

Reputation: 570325

Quoting the section 8.5.2 Deploying a Java EE Application of the Java EE Specification v6:

The deployment tool must first read the Java EE application deployment descriptor from the application .ear file (META-INF/application.xml). If the deployment descriptor is present, it fully specifies the modules included in the application. If no deployment descriptor is present, the deployment tool uses the following rules to determine the modules included in the application.

In other words, when providing an application.xml, you need indeed to include all modules in it.

Upvotes: 5

Jarek Rozanski
Jarek Rozanski

Reputation: 800

According to JSR316, context root must be specified in META-INF/application.xml, otherwise web module will acquire name of its deployment package stripped of .war extension.

Upvotes: 0

vkraemer
vkraemer

Reputation: 9892

I cannot get to the jcp.org site to check the final draft of JSR316... which should have the definitive answer...

My best advice would be to create a 'complete' application.xml, though.

Upvotes: 1

Related Questions