Use CXF libraries in Wildfly deployment with Maven artifact provided

mr-anderson picture mr-anderson · Jun 28, 2015 · Viewed 12.1k times · Source

Im trying to deploy a project containing an JAX-WS Interface to a wildfly 8.2 server. The project is packed as a war. Within that project I would like to use interceptors.

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

I'm using Maven with the "provided" tag, in order to not receiving the following error:

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.

That looks like this:

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

But if I do so the library cannot be found at runtime:

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

I have already tried adding the dependency via the MANIFEST.MF file using maven:

            <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>

I don't know what to do, any suggestions?

Answer

mr-anderson picture mr-anderson · Jun 28, 2015

It turned out adding a jboss-deployment-structure.xml file to WEB-INF folder with the following content did the trick:

<?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>

Eventhough I tried it before with org.apache.cxf only,I had to add org.apache.cxf.impl