JBoss ignoring context path in application.xml when using @WebService and @Stateless in war file

2.2k Views Asked by At

I have an ear file that consists of a war file together with a number of jar files. The application.xml with the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC
    "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
    "http://java.sun.com/dtd/application_1_3.dtd">
<application>
  <display-name>Web Application</display-name>
    <module>
        <web>
           <web-uri>web-endpoint-1.0.war</web-uri>
           <context-root>/web</context-root>
        </web>
    </module>
    <module>
        <ejb>backend-1.1.jar</ejb>
    </module>
</application>

This ear file is being deployed to JBOSS AS 6 however the context-root is being ignored and the name of the war file is being used for the context root.

Can someone point out why Jboss is ignoring what is being specified in the application.xml?

Thanks!!


I have looked further into the problem and the problem is this:

In the WAR file, I have a stateless session bean to implement a web service. When I remove the stateless session beans, the context root now matches the one specified in the application.xml as required. What is the best solution to implement a web service in a war file using the @WebService annotation?

2

There are 2 best solutions below

0
On BEST ANSWER

I found a solution for this problem as follows.

Instead of using @Stateless annotation for the class, I changed the class with the @WebService annotation to a servlet.
This workaround eliminated the need for stateless session beans in the war file even though this should be possible for JavaEE6.
The context root of the war file when deployed now corresponds to that in the application.xml file.

0
On

Try adding the annotation @WebContext(contextRoot="/YourContextRoot").

This just worked for me.