tags:

views:

389

answers:

3

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?

+1  A: 

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.

vkraemer
I think you're right. According to the spec:"The deployment tool must first read the Java EE application deployment descriptorfrom the application .ear file (META-INF/application.xml). If the deploymentdescriptor 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."I should have looked at that first, I suppose. :( Thank you for your help!
Rintoul
A: 

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.

jarekrozanski
If you decide to skip application.xml, you can modify context root name by application server specific configuration. You may then use EJB 3.1 and other JEE6 goodness within your WAR package.For example, in Glassfish 3, you can modify context root in WEB-INF/sun-web.xml.
jarekrozanski
Since I am using Glassfish v3, I did try the suggestion by jarekronzanski, but it didn't seem to work. I am using NetBeans as an IDE and am launching the application through some mechanism which I do not fully understand, so something could be going wrong there...
Rintoul
Can you try exporting WAR package from NetBeans and deploying it out of IDE?Check if in you WEB-INF/sun-web.xml you can find entry:<sun-web-app error-url=""> <context-root>/MY_NEW_CONTEXT_NAME</context-root> <!-- ... the rest of xml --></sun-web-app>
jarekrozanski
A: 

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.

Pascal Thivent