【问题标题】:WAR failed to deployWAR 部署失败
【发布时间】:2016-10-24 05:53:37
【问题描述】:

我有一个在 TomEE 中运行良好的 Maven JEE 应用程序。我在 Netbeans 中创建了一个 SOAP Web 服务:New - Web Service,它创建了一个简单的“hello”服务。由于某种原因,我收到一条消息

您选择的网络服务器似乎不支持 JSR 109 规格。使 Web 服务器能够处理带注释的 Web 服务,应创建 sun-jaxws.xml 文件和 servlet 需要在 web.xml 文件中生成 Web 服务的条目

我接受、清理、构建...无论我做什么,每次打开 Netbeans 时都会收到此消息。就像变化不是持久的一样。

然后主要问题是当我尝试运行项目时。我得到一长串错误

在服务器日志中

SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! org.apache.catalina.core.DefaultInstanceManager cannot be cast to org.apache.tomee.catalina.JavaeeInstanceManager
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:292)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5066)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5584)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)

在日志中

SEVERE: Unable to deploy collapsed ear in war StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WebServiceTest]
org.apache.openejb.OpenEJBException: Unable to load servlet class: com.sun.xml.ws.tx.coord.v11.endpoint.RegistrationRequesterPortImpl: null
    at org.apache.openejb.config.WsDeployer.processPorts(WsDeployer.java:234)
....
Caused by: java.lang.NullPointerException
    at org.apache.openejb.config.WsDeployer.readWsdl(WsDeployer.java:451)

SEVERE: ContainerBase.removeChild: destroy: 
org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([before_destroy]) for component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WebServiceTest]] in state [STARTING_PREP]
    at org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:401)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:291)
....
SEVERE: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WebServiceTest]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
....
Caused by: org.apache.tomee.catalina.TomEERuntimeException: org.apache.openejb.OpenEJBException: Unable to load servlet class: com.sun.xml.ws.tx.coord.v11.endpoint.RegistrationRequesterPortImpl: null
    at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1270)
....
Caused by: org.apache.openejb.OpenEJBException: Unable to load servlet class: com.sun.xml.ws.tx.coord.v11.endpoint.RegistrationRequesterPortImpl: null
    at org.apache.openejb.config.WsDeployer.processPorts(WsDeployer.java:234)
....
Caused by: java.lang.NullPointerException
    at org.apache.openejb.config.WsDeployer.readWsdl(WsDeployer.java:451)
....
SEVERE: Error deploying configuration descriptor C:\Program Files\Apache-Tomee-jaxrs-1.7.4\conf\Catalina\localhost\WebServiceTest.xml
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WebServiceTest]]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:903)
....

编辑

我已经添加了这些依赖项,但在构建/运行时仍然遇到相同的错误

<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-catalina-ws -->
<dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>tomcat-catalina-ws</artifactId>
    <version>7.0.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.xml/jaxrpc-api -->
<dependency>
    <groupId>javax.xml</groupId>
    <artifactId>jaxrpc-api</artifactId>
    <version>1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/wsdl4j/wsdl4j -->
<dependency>
    <groupId>wsdl4j</groupId>
    <artifactId>wsdl4j</artifactId>
    <version>1.6.2</version>
</dependency>

除了 Maven 依赖项之外,我还手动将文件 jaxrpc-api-1.1.jartomcat-catalina-ws-7.0.5.jar 复制到了 TomEE lib 文件夹中。文件wsdl4j-1.6.3.jar 已经存在。我重新启动了 Netbeans。不确定这些是需要的罐子,但它们不能解决问题。

【问题讨论】:

    标签: java web-services maven netbeans


    【解决方案1】:

    您收到此错误是因为 Tomcat 开箱即用不符合 JSR-109。我在 Tomcat documentation 中发现了这一点,这可能会对您有所帮助:

    Web 服务支持 (JSR 109)

    Tomcat 为 JSR 109 提供工厂,可用于解析 Web 服务引用。将生成的 catalina-ws.jar 以及 jaxrpc.jar 和 wsdl4j.jar(或 JSR 109 的另一个实现)放在 Tomcat lib 文件夹中。

    用户应该知道 wsdl4j.jar 是根据 CPL 1.0 而不是 Apache 许可证 2.0 版获得许可的。

    【讨论】:

    • 谢谢!这是有希望的,我现在将尝试在 Maven 上找到 JAR。虽然我使用的是 TomEE,如果我没记错的话,它似乎应该像 BalusC 所说的那样工作:stackoverflow.com/questions/14633343/…
    • 检查您的 Tomcat lib 文件夹以确保 JAR 文件在其中。是的,我同意 BalusC 的观点,它应该可以工作。也许这会导致找到真正的解决方案。
    • 我做了,但似乎不起作用(请参阅我的编辑)。我还安装了最新的 TomEE 7 plumee(5 月发布),仍然遇到同样的问题。是否与使用 CXF 的 TomEE 与 Netbeans 创建的 Web 服务不同有关?
    • 我不确定。我暂时将其保留,因为它可能会帮助其他人阅读您的问题。我稍后会删除。
    • 是的,请不要删除。找到可能的错误来源很有帮助
    【解决方案2】:

    我不完全确定为什么会发生此错误...正如 Tim 所说,Tomcat 可能不符合 JSR-109 开箱即用(请参阅他的帖子),但由于我使用的是 TomEE,所以应该没问题。经过多次测试,我看到使用这个nb-configuration.xml文件:

    <?xml version="1.0" encoding="UTF-8"?>
    <project-shared-configuration>
        <!--
        This file contains additional configuration written by modules in the NetBeans IDE.
        The configuration is intended to be shared among all the users of project and
        therefore it is assumed to be part of version control checkout.
        Without this configuration present, some functionality in the IDE may be limited or fail altogether.
        -->
        <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
            <!--
            Properties that influence various parts of the IDE, especially code formatting and the like. 
            You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
            That way multiple projects can share the same settings (useful for formatting rules for example).
            Any value defined here will override the pom.xml file value but is only applicable to the current project.
            -->
            <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>1.7-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
            <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>Tomcat</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
            <org-netbeans-modules-maven-jaxws.generate_5f_nonjsr109>false</org-netbeans-modules-maven-jaxws.generate_5f_nonjsr109>
            <netbeans.hint.jdkPlatform>JDK_1.8</netbeans.hint.jdkPlatform>
        </properties>
    </project-shared-configuration>
    

    正在帮助 [至少] 告诉 Netbeans 不要提出这个信息(我相信)。然后使用通常的 Web 服务注释(@WebService(serviceName = "...")@WebMethod(operationName = "...")@WebResult(name = "...")...)并在某些服务器重新启动并确保 context.xml 有效后,部署 Web 服务。我希望它可以帮助有同样问题的人。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-27
      • 2018-09-13
      • 2014-07-25
      • 2014-06-24
      • 2019-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多