部署失败:WAR文件无法部署。

5

我有一个在TomEE运行正常的Maven JEE应用程序。我在Netbeans中创建了一个SOAP Web服务:新建 - Web服务,它创建了一个简单的“hello”服务。但出现了以下错误信息:

enter image description here

您选择的Web服务器似乎不支持JSR 109规范。要使Web服务器能够处理注释的Web服务,应该创建sun-jaxws.xml文件并在web.xml文件中生成Web服务的servlets条目。

我尝试接受、清理、构建……无论我做什么,每次打开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依赖之外,我还在TomEE lib文件夹中手动复制了jaxrpc-api-1.1.jartomcat-catalina-ws-7.0.5.jar文件。wsdl4j-1.6.3.jar文件已经存在。我重新启动了Netbeans。不确定这些是必需的jar包,但它们无法解决问题。

2个回答

3
您之所以遇到此错误,是因为Tomcat默认情况下不符合JSR-109标准。在Tomcat的文档中可以找到相关信息,这可能会对您有所帮助:
Web Services支持(JSR 109)
Tomcat提供了用于解析Web服务引用的JSR 109工厂。将生成的catalina-ws.jar以及jaxrpc.jar和wsdl4j.jar(或另一种JSR 109实现)放置在Tomcat lib文件夹中。
用户应注意,wsdl4j.jar根据CPL 1.0许可证授权,并非Apache许可证版本2.0。

谢谢!这很有希望,我现在会尝试在Maven上找到JAR文件。虽然我正在使用TomEE,如果我没记错的话,根据BalusC在这里所说,它应该可以工作:https://stackoverflow.com/questions/14633343/is-it-sufficient-to-use-only-catalina-ws-jar-to-have-a-rest-webservice-in-tomcat - user1156544
检查您的Tomcat lib文件夹,确保JAR文件在其中。是的,我同意BalusC的看法,它应该可以工作。也许这会引导我们找到实际解决方案的路径。 - Tim Biegeleisen
我已经尝试过了,但好像没有起作用(请看我的编辑)。我还安装了最新的TomEE 7 plumee(在五月份发布),但仍然存在同样的问题。这是否与TomEE使用CXF不同于Netbeans创建的Web服务有关呢? - user1156544
我不确定。我会暂时保留这个问题,因为它可能会帮助其他阅读你的问题的人。稍后我会删除它。 - Tim Biegeleisen
是的,请不要删除。找到可能的错误来源非常有帮助。 - user1156544

0
我不完全确定为什么会出现这个错误...正如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服务已部署。我希望这能帮助遇到同样问题的人。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接