java - 在提供 Maven Artifact 的 Wildfly 部署中使用 CXF 库

标签 java web-services maven jax-ws wildfly

我正在尝试将包含 JAX-WS 接口(interface)的项目部署到 Wildfly 8.2 服务器。该项目被包装成一场 war 。 在该项目中,我想使用拦截器。

import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
public class ReplyToHeaderInInterceptor extends AbstractSoapInterceptor { /*code*/}

我正在使用带有“provided”标签的 Maven,以免收到以下错误:

Apache CXF library (cxf-rt-bindings-soap-3.1.1.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.

看起来像这样:

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>3.1.1</version>
        <scope>provided</scope>
    </dependency>

但如果我这样做,则在运行时无法找到该库:

Caused by: java.lang.NoClassDefFoundError: org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor

我已经尝试使用 Maven 通过 MANIFEST.MF 文件添加依赖项:

            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
                <warName>backend</warName>
               <archive>
                  <manifestEntries>
                     <Dependencies>org.apache.cxf</Dependencies>
                  </manifestEntries>
               </archive>
            </configuration>
        </plugin>

我不知道该怎么办,有什么建议吗?

最佳答案

事实证明,将具有以下内容的 jboss-deployment-structure.xml 文件添加到 WEB-INF 文件夹就可以了:

<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <deployment>
        <exclusions>
        </exclusions>
        <dependencies>
            <module name="org.apache.cxf" />
            <module name="org.apache.cxf.impl" />
        </dependencies>
    </deployment>
</jboss-deployment-structure>

虽然我之前只用 org.apache.cxf 尝试过,但我不得不添加 org.apache.cxf.impl

关于java - 在提供 Maven Artifact 的 Wildfly 部署中使用 CXF 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31099208/

相关文章:

java - 从数据处理程序写入文件

java - IntelliJ IDEA 中 maven 项目的不同源和 testSource JDK

java - 使用多模块 Maven 应用程序编译 grpc

java - 动态获取当前方法名称的较短方法

java - 录制带有准确时间戳的音频

wcf - WebService 有单独的方法来填充复合类中的属性吗?

ruby-on-rails - 在本地主机 :4567 but not on IP 上运行的 Ruby Sinatra Web 服务

java - 将 Long 数组传递给 JSNI 函数

java - 在 Java (linux) 中获取一段时间内的平均系统 CPU 使用率

java - 使用命令行执行java程序时maven报错