I'm trying to create a simple webservice using Tomcat 7.0.11 on Windows Server 2008 R2 using Metro 2.1. I'm coming from a C#/WCF background trying to get a better understanding on web service interopability. I'm actually following an example from Martin Kalin's book "Java Web Services Up and Running". I have the following:
CATALINA_HOME=c:\tomcat-7.0.11
in the catalina.properties file I have:
server.loader=c:/metro-2.1/bin/*.jar
(note, I also tried adding this path to common.loader too).
I've copied to the following METRO jar files to CALALINA_HOME\lib:
webservices-api.jar, webservices-extra.jar, webservices-extra-api.jar, webservices-rt.jar, webservices-tools.jar
and to CALALINA_HOME\endorsed:
webservices-api.jar
(note, I originally tried using the metro-on-tomcat.xml ant file but it doesn't seem to have been updated for tomcat 7.*)
I've also copied webservices-api.jar to JAVA_HOME\jre\lib\endorsed
I've tried putting the other METRO jars in the above locations aswell too but to no help.
Now, Tomcat starts up ok and initializes METRO ok, here's the relevant section from the catalina log file:
INFO: Deploying web application directory ROOT 18-May-2011 08:00:55 com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextInitialized INFO: WSSERVLET12: JAX-WS context listener initializing 18-May-2011 08:01:07 com.sun.xml.ws.server.MonitorBase createRoot INFO: Metro monitoring rootname successfully set to: com.sun.metro:pp=/,type=WSEndpoint,name=-TempConvertImplService-TempConvertImplPort 18-May-2011 08:01:08 com.sun.xml.ws.transport.http.servlet.WSServletDelegate INFO: WSSERVLET14: JAX-WS servlet initializing
So from that you'd think that Tomcat had loaded all the METRO classes. From what I have gathered WSServlet is part of JAX-WS 2.1 which is shipped as part of METRO so it should have been loaded. But when I actually try to browse to the WSDL of my service I get the following in the localhost log:
SEVERE: Allocate exception for servlet TempConvertWS java.lang.ClassNotFoundException: com.sun.xml.ws.transport.http.WSServlet at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415).... (rest of stack trace)
my sun-jaxws.xml looks like this:
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">
<endpoint
name="TempConvertWS"
implementation="TimeServer.TempConvertImpl"
url-pattern="/tc"
/>
</endpoints>
and the relevant section from my web.xml file is:
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>TempConvertWS</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.WSServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TempConvertWS</servlet-name>
<url-pattern>/tc</url-pattern>
</servlet-mapping>
Can anyone see from that why Tomcat can't find/load the WSServlet class when browsing to the service?
With Tomcat 6, I set shared.loader in catalina.properties and added webservices-api.jar to <catalina-home>\endorsed
That worked like a charm.
For development and testing purposes you could just put the webservices-extra.jar, webservices-extra-api.jar, webservices-rt.jar, webservices-tools.jar into <catalina-home>/lib
instead of using the shared.loader directive. I find that this is also more compatible with Eclipse.
I will test with Tomcat 7 to see if it differs in any way.
*Update: Same trick works for Tomcat 7.0.14
*Update2: I'm sorry I didn't see it at once, but I just noticed that in your web.xml, the specified <servlet-class>
is wrong. It should be com.sun.xml.ws.transport.http.servlet.WSServlet