【问题标题】:javax.servlet.UnavailableException: SRVE0201E: Servlet [my_ws]: not a servlet classjavax.servlet.UnavailableException: SRVE0201E: Servlet [my_ws]: 不是 servlet 类
【发布时间】:2017-02-16 09:36:09
【问题描述】:

我使用 Web 服务 -> 生成 Java Bean 骨架从 WSDL 文件创建了一个 WS。 然后将其发布到 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?谢谢。

【问题讨论】:

  • 它是作为 Eclipse 对话框抛出的,请尝试验证您的 WSDL 的结构

标签: java servlets jax-ws web.xml


【解决方案1】:

通过删除web.xml 解决了问题。

我想删除 &lt;servlet&gt;&lt;servlet-mapping&gt; 标记也可以解决问题。

【讨论】:

  • 谢谢。是的,只需要从 web.xml 中删除标签
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-11
  • 2021-04-28
  • 2021-01-14
  • 2018-06-27
相关资源
最近更新 更多