Use CXF libraries in Wildfly deployment with Maven artifact provided
Asked Answered
M

2

10

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?

Mydriasis answered 28/6, 2015 at 11:22 Comment(1)
Did you include the mapping of the interceptor in any spring config file?Lost
M
6

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

Mydriasis answered 28/6, 2015 at 20:37 Comment(2)
Amazing! Just what I wanted. Pitty it doesn't work for me :( afer several hours of tweaking. All deps in poms with scope provided? Meaning, I have a war and an ear too; maybe it's not your case.Lost
Probably the answer about disabling webservices replies to this (with yes).Lost
S
4

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

Squint answered 29/2, 2016 at 10:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.