Question

I'm new to writing web services, and am struggling with understanding how to specify the context root.

I've got my class annotated with

@Service 
@javax.jws.WebService(endpointInterface=  "com.domain.clientservices.lendingsimulation.model.v1.LendingSimulationServicePortType", targetNamespace="http://www.domain.com/ClientServices/LendingSimulation/V1.2", serviceName="LendingSimulationService", portName="LendingSimulationServicePort")

but I am not sure how to configure the context-root/path for it. I read that I could configure it as a servlet in web.xml, but that seems to be the case for a web service that is not annotate. Am I wrong? I have tried the following configuration in web.xml:

<servlet>
    <description>This is the description for the LendingSimulation Service</description>
    <display-name>Lending Simulation Service</display-name>
    <servlet-name>LendingSimulationService</servlet-name>
    <servlet-class>com.domain.clientservices.lendingsimulation.service.LendingSimulationServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>LendingSimulationService</servlet-name>
    <url-pattern>/WebService</url-pattern>
</servlet-mapping>

however, when I launch in JBoss, I get an error msg:

17:39:33,710 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/LendingSimulationService].[LendingSimulationService]] (http--127.0.0.1-8080-2) Allocate exception for servlet LendingSimulationService: java.lang.ClassCastException: com.domain.clientservices.lendingsimulation.service.LendingSimulationServiceImpl incompatible with javax.servlet.Servlet
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1156) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:952) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
... (omitted for brevity)

I've read that I can configure jboss-web.xml specifically, but I assume there is a more generic way of doing this that can be applied to all app servers - isn't there? Or must I configure the service independently, depending on the AS that I am deploying to (ie: one way for Tomcat, one way for GlassFish, one way for JBoss, one way for WebSphere, etc...).

Is there an annotation I can use to specify my path for the web-service? Or a config param in the web.xml file?

Thanks!

Eric

Was it helpful?

Solution

Turns out that the JBoss error I was getting was due to the webservices module not being enabled. In JBoss7.0/7.1, you need to run the standalone-preview.xml config to get webservices for an out-of-box download: ie: standalone.sh --server-config=standalone-preview.xml. That eliminated the ClassCast/Servlet exception. However my question still remains if there is not a better/other way to accomplish this (perhaps via annotations) than declaring it as a servlet in web.xml.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top