javax.servlet.UnavailableException:SRVE0201E:Servlet [my_ws]:不是servlet类

时间:2017-02-16 09:36:09

标签: java servlets jax-ws web.xml

我使用Web服务从WSDL文件创建了一个WS - >生成Java Bean Skeleton。 然后在web.xml上发布它并尝试使用Web Services Explorer访问它。

然后我得到了例外:  javax.servlet.UnavailableException:SRVE0201E:Servlet [my_ws]:不是servlet类

我有那些生成的文件:

HelloWorld界面:

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);

}

以及以下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;
    }

}

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>

我更改了真实姓名和内容,因为我无法发布它。 但问题无关紧要。

为什么我不能发布这个WS?感谢。

1 个答案:

答案 0 :(得分:0)

删除web.xml

解决了问题

我认为删除<servlet><servlet-mapping>代码也可以解决问题。