Caused by: java.lang.NoClassDefFoundError: org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder

tiitrfma picture tiitrfma · Jun 20, 2016 · Viewed 8.1k times · Source
I am migrating my application from jboss-eap-5.1 to jboss-eap-6.4.0. My application is using spring 3.1.1 related jar and apache-cxf-2.7.7 jars. 

Ear file structure is as below 
EAR/lib - contains all the jar which is common for wars.
app1.war/lib - contains jars required for it
app2.war/lib - contains jars required for it


I have also excluded modules for webservice, org.jboss.as.jaxrs & ejb3 from  standalong.xml config file.  


Spring jars :
spring-orm-3.1.1.RELEASE.jar
spring-aop-3.1.1.RELEASE.jar                spring-oxm-3.2.4.RELEASE.jar
spring-asm-3.1.1.RELEASE.jar                spring-test-3.2.4.RELEASE.jar
spring-beans-3.1.1.RELEASE.jar              spring-tx-3.1.1.RELEASE.jar
spring-context-3.1.1.RELEASE.jar            spring-web-3.2.4.RELEASE.jar
spring-core-3.1.1.RELEASE.jar               spring-webmvc-3.2.4.RELEASE.jar
spring-data-commons-core-1.1.0.RELEASE.jar  spring-ws-core-2.1.4.RELEASE.jar
spring-data-jpa-1.0.3.RELEASE.jar           spring-ws-test-2.1.4.RELEASE.jar
spring-expression-3.1.1.RELEASE.jar         spring-xml-2.1.4.RELEASE.jar

javaw.ws.rs jar containes below jar
javax.ws.rs-api-2.0-m10.jar

apache-cfx-jars packaged in ear/lib are 
cxf-api-2.7.7.jar                     cxf-rt-frontend-jaxrs-2.7.7.jar
cxf-rt-bindings-soap-2.7.7.jar        cxf-rt-frontend-jaxws-2.7.7.jar
cxf-rt-bindings-xml-2.7.7.jar         cxf-rt-frontend-simple-2.7.7.jar
cxf-rt-core-2.7.7.jar                 cxf-rt-transports-http-2.7.7.jar
cxf-rt-databinding-jaxb-2.7.7.jar     cxf-rt-transports-local-2.7.7.jar
cxf-rt-features-clustering-2.7.7.jar


now when i deploy , i am getting below error. I am not sure how to resolve this error as  below
7:33:07,784 INFO  [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (pool-6-thread-2) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring

07:33:07,785 INFO [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (pool-5-thread-1) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 07:33:07,790 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] (pool-6-thread-2) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@75b6f75e: defining beans [cxf,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,servletContextReaderComponent,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,signatureAlgorithm,serviceAuthManager,authServiceProvider,soaErrorBundle,soaErrorMapper,soaExceptionHandler,soaClientPolicyEvaluator,com.walmart.platform.soa.client.listener.SOAClientLifeCycleListener#0,clientHeaderOutInterceptor,clientLoggingOutInterceptor,clientHeaderInInterceptor,clientLoggingInInterceptor,serviceAuthOutInterceptor,clientPolicyOutInterceptor,clientPolicyInInterceptor,cxf.config2,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy @

07:33:08,015 ERROR [stderr] (Thread-147) 2016-06-20 07:33:08.014 WARN net.spy.memcached.auth.AuthThread: Authentication failed to /172.16.113.154:11210, Status: {OperationStatus success=false: Invalid arguments} 07:33:08,026 WARN [org.jboss.modules] (pool-6-thread-2) Failed to define class org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder in Module "deployment.smcfs.ear:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilder (Module "deployment.smcfs.ear:main" from Service Module Loader) at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:487) [jboss-modules.jar:1.3.6.Final-redhat-1] at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:277) [jboss-modules.jar:1.3.6.Final-redhat-1] at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:92) [jboss-modules.jar:1.3.6.Final-redhat-1] at org.jboss.modules.Module.loadModuleClass(Module.java:568) [jboss-modules.jar:1.3.6.Final-redhat-1

When i check errors closely it is failing due to below class not found exception .

]
    at com.walmartlabs.services.util.base.LabsCallable.call(LabsCallable.java:31) [labs-ims-1.0.jar:]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_51]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_51]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_51]

Caused by: java.lang.NoClassDefFoundError: org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.8.0_51] at java.lang.ClassLoader.defineClass(ClassLoader.java:760) [rt.jar:1.8.0_51] at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:361) [jboss-modules.jar:1.3.6.Final-redhat-1] at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:482) [jboss-modules.jar:1.3.6.Final-redhat-1] ... 148 more Caused by: java.lang.ClassNotFoundException: org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertionBuilder from [Module "deployment.smcfs.ear:main" from Service Module Loader] at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.6.

    *********************************************8

      at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_51]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_51]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_51]

Caused by: java.lang.NoClassDefFoundError: org/apache/cxf/ws/policy/AbstractPolicyInterceptorProvider at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.8.0_51] at java.lang.ClassLoader.defineClass(ClassLoader.java:760) [rt.jar:1.8.0_51] at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:361) [jboss-modules.jar:1.3.6.Final-redhat-1] at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:482) [jboss-modules.jar:1.3.6.Final-redhat-1] ... 148 more Caused by: java.lang.ClassNotFoundException: org.apache.cxf.ws.policy.AbstractPolicyInterceptorProvider from [Module "deployment.smcfs.ear:main" from Service Module Loader] at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.6.Final-redhat-1] a

    ************************************

Any suggestion how to overcome this problem

Thanks

Answer

cabaji99 picture cabaji99 · Oct 16, 2017

I had to add this following dependencies to my pom to avoid that error:

 <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxrs</artifactId>
        <version>3.2.0</version>
    </dependency>

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-ws-policy</artifactId>
        <version>3.2.0</version>
    </dependency>

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-wsdl</artifactId>
        <version>3.2.0</version>
    </dependency>


    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>3.2.0</version>
    </dependency>