问题
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!
回答1:
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.
回答2:
Your CXF libraries scope is <cxf.scope>provided</cxf.scope>
. I am not sure if JBoss EAP 6 is embedding CXF-jaxrs (the REST part of CXF - you should inspect the jboss version of CXF 2.4.x-redhat-1). I think it uses Rest Easy instead. So it will not find org/apache/cxf/jaxws/JaxWsProxyFactoryBean
.
Change the scope of cxf-rt-frontend-jaxws
from provided
to compile
.
See https://access.redhat.com/site/articles/112673 to get the list of all embedded libs inside Jboss EAP 6.x
来源:https://stackoverflow.com/questions/17594545/jboss-6-eap-jaxwsproxyfactorybean-noclassdeffounderror