为什么在 glassfish 4 上需要 sun-jaxws.xml 文件?

Why do I need sun-jaxws.xml file on glassfish 4?

我正在向 JAX-WS 世界迈出第一步,并使用 glassfish 4。

我刚刚尝试重建 JavaEE7 Oracle Jax-WS 示例并拥有以下网络服务:

@WebService
public class Hello {

    @WebMethod
    public String sayHello(String name) {
        System.out.println("Webservice sayHello called...");
        return "Hello " + name;
    }
}

仅此而已..我已经将它部署在 glassfish 上,我可以使用测试器,我可以看到 WSDL - 很好。

现在我正在编写应由 JSF2 视图调用的客户端。bean 来了:

@Named
@RequestScoped
public class HelloServiceClient {

    @WebServiceRef(wsdlLocation="http://localhost:8080/HelloService/HelloService?WSDL")
    private HelloService service;

    public String callHello() {
        Hello helloPort = service.getHelloPort();
        return helloPort.sayHello(" JSF2 View!");
    }

    public String callWSSayHello(String name) {
        Hello helloPort = service.getHelloPort();
        return helloPort.sayHello(name);
    }
}

还有一个简单的视图只是调用 callHello() 方法并显示结果。

我将该应用程序部署到同一个 glassfish 服务器并收到以下错误:

java.io.IOException: com.sun.enterprise.admin.remote.RemoteFailureException: Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: com.sun.xml.ws.transport.http.servlet.WSServletException: WSSERVLET11: Laufzeitdeskriptor konnte nicht geparst werden: javax.xml.ws.WebServiceException: Laufzeitdeskriptor "/WEB-INF/sun-jaxws.xml" fehlt. Please see server.log for more details.

所以我不理解 sun-jaxws 的概念 - 尽管 - oracle 文档和示例没有告诉我任何关于它的信息。

我是不是做错了什么 - 也许是在我的 IDE 或其他地方?

我找到了问题的答案:

我的 IDE 自动将 WSServlet 作为侦听器添加到我的 web.xml -> 如果您从 web.xml 中删除它,它会按预期工作。