Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JBoss 6 EAP JaxWsProxyFactoryBean NoClassDefFoundError

I'm migrating an application from JBoss 6.1.0 JBoss EAP 4.2.xa.

I know I have changed many things, one of the most important is that JBoss now includes most of the framework / most used libraries (modules), which is great (war files smaller).

Now, I have two applications, both mounted with Spring / CXF and Maven2. One exposes a web services and the second for the first client.

The problem is in the client application, at runtime, when I try to instantiate the proxy web service I get the following error:

------ java.lang.NoClassDefFoundError: org/apache/cxf/jaxws/JaxWsProxyFactoryBean 
at es....MyFactory.getService_WSC(MyFactory.java:59) 
...
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) 
...
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
...
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920) 
at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.ClassNotFoundException: org.apache.cxf.jaxws.JaxWsProxyFactoryBean from [Module "deployment.myapp.war:main" from Service Module Loader] 
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:196) 
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:444) 
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:432) 
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:399) 
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:374) 
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:119) ... 21 more ------

In my pom.xml, I have the following (CXF as provided):

<properties>    
    <cxf.version>2.6.6</cxf.version>
    <cxf.scope>provided</cxf.scope>
</properties>

    <!-- CXF -->
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>${cxf.version}</version>
        <scope>${cxf.scope}</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>${cxf.version}</version>
        <exclusions>
            <exclusion>
                <artifactId>commons-logging</artifactId>
                <groupId>commons-logging</groupId>
            </exclusion>
        </exclusions>
        <scope>${cxf.scope}</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-ws-security</artifactId>
        <version>${cxf.version}</version>
        <scope>${cxf.scope}</scope>
    </dependency>

Could include CXF libraries but presumably this is not necessary and that JBoss EAP 6 already has them?, Though, if this is so why do I get the error above NoClassDefFoundError -> Caused by: java.lang.ClassNotFoundException?

Thank you!

like image 647
jpadron Avatar asked Mar 24 '23 05:03

jpadron


1 Answers

Finally I've solved it.

First of all, thank willome response. By the nature of the services architecture (implemented with Apache CXF) I preferred to solve using CXF.

JBoss EAP 6 embed a full version of CXF framework, with the particularity that is "divided" into modules and the key has been to identify exactly the modules included in the application.

The good thing about all this is that the war now are very light, and you can NOT include the vast majority of frameworks / libraries ... in my case I went from one war of 30MB to final 5MB.

Then finally I added the file to the application jboss-deployment-structure.xml, with the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="org.jboss.ws.cxf.jbossws-cxf-client" services="import" />
            <module name="org.apache.cxf.impl">
                <imports>
                    <include path="META-INF"/>
                    <include path="META-INF/cxf"/>
                </imports>
            </module>
            <!-- ... -->
        </dependencies>
    </deployment>
</jboss-deployment-structure>

And I kept the scope "provided" in my pom.xm for CXF framework.

like image 117
jpadron Avatar answered Apr 07 '23 14:04

jpadron