Search code examples
javaservletsjax-wsweb.xml

javax.servlet.UnavailableException: SRVE0201E: Servlet [my_ws]: not a servlet class


I created a WS from a WSDL file using Web Services -> Generate Java Bean Skeleton. Then published it on web.xml and tried to access it using Web Services Explorer.

Then I got the exception: javax.servlet.UnavailableException: SRVE0201E: Servlet [my_ws]: not a servlet class

I have those generated files:

HelloWorld interface:

package helloWorld;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;

@WebService(name = "HelloWorld", targetNamespace = "[something]")
@XmlSeeAlso({
    ObjectFactory.class
})
public interface HelloWorld
{
    @WebMethod(action = "sayHello")
    @WebResult(name = "sayHelloReturn", targetNamespace = "")
    @RequestWrapper(localName = "sayHello", targetNamespace = "[something]", className = "helloworld.HelloWorld")
    @ResponseWrapper(localName = "sayHelloResponse", targetNamespace = "[something]", className = "helloworld.HelloWorldResponse")
    public String sayHello(
        @WebParam(name = "userIdStr", targetNamespace = "")
        String userIdStr,
        @WebParam(name = "text", targetNamespace = "")
        Integer text);

}

and the following Impl:

package helloWorld;

import helloworld.HelloWorld


@javax.jws.WebService(endpointInterface = "helloworld.HelloWorld", targetNamespace = "[something]", serviceName = "HelloWorldService", portName = "HelloWorldImpl")
public class HelloWorldImpl
{

    public String sayHello(String userIdStr, Integer text)
    {
        return "Hello " + userIdStr + ", " + text;
    }

}

The web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee     http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>Test</display-name>

<servlet>
    <servlet-name>helloworld_HelloWorld</servlet-name>
    <servlet-class>helloworld.HelloWorldImpl</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>helloworld_HelloWorld</servlet-name>
    <url-pattern>services/HelloWorldImpl</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
</welcome-file-list>

I changed the real names and impl content because I can't publish it. But it's not matter to the problem.

Why can't I publish this WS? thanks.


Solution

  • Problem solved by deleting the web.xml.

    I suppose that removing the <servlet> and <servlet-mapping> tags can also do the trick.