JBoss(Wildfly 10.0)上的Java Web应用程序未通过Eclipse部署



我正在使用Tomcat v8.0来运行我的Java Web应用程序,但是我想尝试JBoss。我通过Eclipse添加了Wildfly 10.0(也通过Eclipse下载了运行时)。

服务器启动时出现一些错误。我可以很好地访问http://localhost:8080,我将看到野蝇的起始页。不过,我无法加载我的网络应用程序。

这是我得到的错误:

15:57:49,657 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."NpCWS.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."NpCWS.war".PARSE: WFLYSRV0153: Failed to process phase PARSE of deployment "NpCWS.war"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYWS0059: Apache CXF library (cxf-2.7.18.jar) detected in ws endpoint deployment; either provide a proper deployment replacing embedded libraries with container module dependencies or disable the webservices subsystem for the current deployment adding a proper jboss-deployment-structure.xml descriptor to it. The former approach is recommended, as the latter approach causes most of the webservices Java EE and any JBossWS specific functionality to be disabled.
    at org.jboss.as.webservices.deployers.WSLibraryFilterProcessor.deploy(WSLibraryFilterProcessor.java:70)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
    ... 5 more

我看到它说它是由Apache CXF引起的,但我无法弄清楚如何让 JBoss 使用我的版本。我知道 JBoss 有自己的Apache CXF罐,但我也不明白如何改变我的beans.xmlweb.xml来反映这种变化。

我在网上找到的所有解决方案都是针对Maven项目,但我的解决方案只是一个简单的动态Web项目。

这是我的beans.xmlweb.xml

beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
    <import resource="classpath:META-INF/cxf/cxf.xml" />
    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
    <!-- HELLO SERVICE -->
    <jaxws:endpoint xmlns:tns="http://ws.cloudlet.org/" id="helloservice"
        implementor="org.cloudlet.ws.HelloServiceImpl" wsdlLocation="wsdl/test/helloserviceimpl.wsdl"
        endpointName="tns:HelloServiceImplPort" serviceName="tns:HelloServiceImplService"
        address="/HelloServiceImplPort">
        <jaxws:features>
            <bean class="org.apache.cxf.feature.LoggingFeature" />
        </jaxws:features>
    </jaxws:endpoint>
    <!-- CALCULATOR SERVICE -->
    <jaxws:endpoint xmlns:tns="http://ws.cloudlet.org/" id="calculatorservice"
        implementor="org.cloudlet.ws.CalculatorServiceImpl" wsdlLocation="wsdl/test/calculatorserviceimpl.wsdl"
        endpointName="tns:CalculatorServiceImplPort" serviceName="tns:CalculatorServiceImplService"
        address="/CalculatorServiceImplPort">
        <jaxws:features>
            <bean class="org.apache.cxf.feature.LoggingFeature" />
        </jaxws:features>
    </jaxws:endpoint>
</beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    id="WebApp_ID" version="3.1">
    <display-name>NpCWS</display-name>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
        <description>Apache CXF Endpoint</description>
        <display-name>cxf</display-name>
        <servlet-name>cxf</servlet-name>
        <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>cxf</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>60</session-timeout>
    </session-config>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>WEB-INF/cxf-beans.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
</web-app>

任何帮助将不胜感激!我真的很想学习如何使用 JBoss。谢谢!

您的答案在 WildFly 为您生成的日志中:

提供适当的部署,将嵌入式库替换为容器模块依赖项,或禁用当前部署的 Web 服务子系统,向其添加适当的 JBos-deployment-structure.xml 描述符。建议使用前一种方法,因为后一种方法会导致大多数 Web 服务 Java EE 和任何特定于 JBossWS 的功能被禁用。

这意味着您需要提供自己的模块依赖项,以便 WildFly 绕过选择自己的Apache CXF版本,而是选择您的版本。

创建自定义模块、module.xmljboss-deployment-structure.xml来完成此操作。

有关如何执行此操作的更多详细信息,请参阅此处:https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7

相关内容

最新更新