Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(JAVA) Wildfly 10 CXF native dependency module issues

I'm trying to migrate from wildfly8 to wildfly10 .. by the same way i'm upgrade some dependency like spring,hibernate and CXF ... but i have some issue with CXF embedded module from wildfly. on wildfly i was on 2.7.8 version on CXF to 3.1.4 on wildfly 10.

here my pom.xml

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

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>${cxf.version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-ws-security</artifactId>
        <version>${cxf.version}</version>
        <scope>provided</scope>
    </dependency>

    <!-- jaxrs is not in wildfly embedded module -->
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxrs</artifactId>
        <version>${cxf.version}</version>
        <scope>compile</scope>
        <!-- 
        <exclusions>
            <exclusion>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-bindings-xml</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-core</artifactId>
            </exclusion>
        </exclusions>
         -->
    </dependency>

here jboss-deployment-structure.xml

<deployment>
    <dependencies>
        <module name="org.apache.cxf" export="true">
            <imports>
                <include path="META-INF**" />
                <include path="META-INF/cxf**" />
            </imports>
        </module>

        <module name="org.apache.cxf.impl" export="true">
            <imports>
                <include path="META-INF**" />
                <include path="META-INF/cxf**" />
            </imports>
        </module>
    </dependencies>
</deployment>

beans.xml for webservice configuration

    <import resource="classpath:META-INF/cxf/cxf.xml" /> 
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> 
    <import resource="classpath:META-INF/cxf/cxf-extension-*.xml" />
    <import resource="classpath:META-INF/cxf/**.xml" />
    <bean id="restService" class="com.itoptics.epcmobilereader.webservice.WebService" />
    <bean id="authenticationInterceptor"
class="com.itoptics.epcmobilereader.interceptor.PolicyAuthenticationInterceptor">
    </bean>
    <bean id="authorizationQueryInterceptor"class="org.apache.cxf.interceptor.security.SimpleAuthorizingInterceptor">
        <property name="methodRolesMap">
            <map>
                <entry key="autorisation" value="ROLE_CUSTOMER" />
            </map>
        </property>
    </bean>
    <jaxrs:server id="resteProService" address="/EasyCaseEPC">
        <jaxrs:serviceBeans>
            <ref bean="restService" />
        </jaxrs:serviceBeans>
        <jaxrs:providers>
            <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
        </jaxrs:providers>
     <jaxrs:inInterceptors>
            <ref bean="authenticationInterceptor" />
        </jaxrs:inInterceptors> 
    </jaxrs:server>

And finally my issue .... NoClassDefFoundError

Caused by: java.lang.NoClassDefFoundError: Failed to link org/apache/cxf/transport/servlet/CXFServlet (Module "org.apache.cxf.impl:main" from local module loader @33e5ccce (finder: local module finder @5a42bbf4 (roots: /home/xxx/Desktop/wildfly-10.0.0.Final/modules,/home/xxx/Desktop/wildfly-10.0.0.Final/modules/system/layers/base))): org/springframework/context/ApplicationListener

This class refer to web.xml

<servlet>
    <servlet-name>CXFServlet</servlet-name>
    <display-name>CXF Servlet</display-name>
    <servlet-class>
        org.apache.cxf.transport.servlet.CXFServlet
    </servlet-class>
    <load-on-startup>2</load-on-startup>
</servlet>

This projet worked fine on CXF 2.7.4 on wildfly 8 , the problem happen when I tried to migrate on wildfly 10 and using CXF embedded

Projet work if I exclude wildfly's module and embeds all dependencies ( maven scope compile instead provided )

I suppose the problem is due to a bad wildfly's module configuration.

Thanks for your time,

Regards,

like image 378
cmagnus Avatar asked Nov 30 '25 00:11

cmagnus


1 Answers

I had exactly this same problem when migrate app between JBoss 7 to Wildfly 10.1

Failed to link org/apache/cxf/transport/servlet/CXFServlet because java.lang.NoClassDefFoundError: org/springframework/context/ApplicationListener

The reason of this is that the module org.apache.cxf.impl hasn't optional dependency on module org.springframework.spring.

After adding dependency in module org.apache.cxf.impl like below the problem disappeared.

<module name="org.springframework.spring" optional="true">
    <imports>
        <include path="META-INF"/>
    </imports>
</module>

Of course, it is necessary to install org.springframework.spring module. My module.xml (jars and modules depends on what you need) example:

<module xmlns="urn:jboss:module:1.1" name="org.springframework.spring">
    <resources>
        <resource-root path="aopalliance-1.0.jar"/>
        <resource-root path="aspectjweaver-1.6.8.jar"/>
        <resource-root path="cglib-2.2.2.jar"/>
        <resource-root path="spring-aop-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-asm-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-beans-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-context-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-context-support-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-core-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-expression-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-jdbc-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-orm-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-tx-3.1.0.RELEASE.jar"/>
        <resource-root path="spring-web-3.1.0.RELEASE.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.mail.api" />
        <module name="javax.faces.api"/>
        <module name="javax.jms.api"/>
        <module name="javax.annotation.api"/>
        <module name="javax.persistence.api"/>
        <module name="javax.activation.api"/>
        <module name="javax.servlet.api"/>
        <module name="org.apache.commons.logging"/>
        <module name="org.jboss.vfs"/>
        <module name="org.hibernate"/>
        <module name="org.hibernate.validator"/>
        <module name="org.hibernate.commons-annotations"/>
        <module name="asm.asm"/>
    </dependencies>
</module>

If you miss any then get exception like in question but for your missing class - then have to add proper jar to spring module definition.

And second prepare jboss-deployment-structure.xml, my look that:

<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="org.apache.cxf" export="true">
                <imports>
                    <include path="META-INF**"/>
                    <include path="META-INF/cxf**"/>
                </imports>
                <exports>
                    <include path="META-INF"/>
                    <include path="META-INF/cxf"/>
                </exports>
            </module>
            <module name="org.apache.cxf.impl" export="true">
                <imports>
                    <include path="META-INF**"/>
                    <include path="META-INF/cxf**"/>
                </imports>
                <exports>
                    <include path="META-INF"/>
                    <include path="META-INF/cxf"/>
                </exports>
            </module>
            <module name="org.apache.commons.io"/>
            <module name="org.apache.commons.codec"/>
            <module name="org.apache.commons.lang"/>
            <module name="org.apache.commons.beanutils"/>
            <module name="org.apache.commons.collections"/>
            <module  name="org.springframework.spring" export="true" >
                <imports>
                    <include path="META-INF**"/>
                </imports>
                <exports>
                    <include path="META-INF"/>
                </exports>
            </module>
            <module name="org.apache.xerces"/>
            <module name="org.apache.xalan"/>
            <module name="org.slf4j"/>
        </dependencies>
    </deployment>
</jboss-deployment-structure>
like image 145
Dariusz Skrudlik Avatar answered Dec 02 '25 14:12

Dariusz Skrudlik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!