title: WSServlet ClassNotFoundException error on Tomcat 7.0.11 using Metro 2.1
body: <p>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:</p>
  
  <pre><code>CATALINA_HOME=c:\tomcat-7.0.11
  </code></pre>
  
  <p>in the catalina.properties file I have:</p>
  
  <pre><code>server.loader=c:/metro-2.1/bin/*.jar 
  </code></pre>
  
  <p>(note, I also tried adding this path to common.loader too).</p>
  
  <p>I've copied to the following METRO jar files to CALALINA_HOME\lib:</p>
  
  <blockquote>
    <p>webservices-api.jar,
    webservices-extra.jar,
    webservices-extra-api.jar,
    webservices-rt.jar,
    webservices-tools.jar</p>
  </blockquote>
  
  <p>and to CALALINA_HOME\endorsed:</p>
  
  <blockquote>
    <p>webservices-api.jar</p>
  </blockquote>
  
  <p>(note, I originally tried using the metro-on-tomcat.xml ant file but it doesn't seem to have been updated for tomcat 7.*)</p>
  
  <p>I've also copied webservices-api.jar to JAVA_HOME\jre\lib\endorsed</p>
  
  <p>I've tried putting the other METRO jars in the above locations aswell too but to no help.</p>
  
  <p>Now, Tomcat starts up ok and initializes METRO ok, here's the relevant section from the catalina log file:</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>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:</p>
  
  <blockquote>
    <p>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)</p>
  </blockquote>
  
  <p>my sun-jaxws.xml looks like this:</p>
  
  <pre><code>&lt;endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0"&gt;
    &lt;endpoint
        name="TempConvertWS"
        implementation="TimeServer.TempConvertImpl"
        url-pattern="/tc"
      /&gt;
  &lt;/endpoints&gt;
  </code></pre>
  
  <p>and the relevant section from my web.xml file is:</p>
  
  <pre><code>  &lt;listener&gt;
      &lt;listener-class&gt;com.sun.xml.ws.transport.http.servlet.WSServletContextListener&lt;/listener-class&gt;
    &lt;/listener&gt;
    &lt;servlet&gt;
      &lt;servlet-name&gt;TempConvertWS&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sun.xml.ws.transport.http.WSServlet&lt;/servlet-class&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;TempConvertWS&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/tc&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>Can anyone see from that why Tomcat can't find/load the WSServlet class when browsing to the service?</p>