Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use CXF libraries in Wildfly deployment with Maven artifact provided

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?

like image 625
mr-anderson Avatar asked Jun 28 '15 11:06

mr-anderson


2 Answers

The other option is to use your own structure, than the modules(versions) offered in Wildfly server deployment. This is done with jboss-deployment-structure.xml file to WEB-INF with this content:

  <deployment>
    <exclude-subsystems>
        <subsystem name="webservices" /> 
    </exclude-subsystems>  
  </deployment>

This will disable webservice framework included in Wildfly and use war included libraries(lib jars)

This is mentioned in related question/answer: How to access CXF jars from Wildfly (Jboss) for ws endpoints

like image 98
zhrist Avatar answered Sep 25 '22 09:09

zhrist


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

like image 20
mr-anderson Avatar answered Sep 24 '22 09:09

mr-anderson