grails cxf BeanCreationException

时间:2015-09-25 08:10:10

标签: grails cxf

我使用grails cxf-Plugin并且它在本地工作正常,但是当我在tomcat服务器上部署它时我得到了一个Erro:

ERROR context.GrailsContextLoaderListener  - Error initializing the application: Error creating bean with name 'cxf': 
Instantiation of bean failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.apache.cxf.bus.spring.SpringBus]: 
Constructor threw exception; nested exception is org.apache.cxf.bus.extension.ExtensionException: Could not load extension class org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl.
        org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cxf': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.apache.cxf.bus.spring.SpringBus]: Constructor threw exception; nested exception is org.apache.cxf.bus.extension.ExtensionException: Could not load extension class org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl.
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.apache.cxf.bus.spring.SpringBus]: Constructor threw exception; nested exception is org.apache.cxf.bus.extension.ExtensionException: Could not load extension class org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl.
... 5 more
Caused by: org.apache.cxf.bus.extension.ExtensionException: Could not load extension class org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl.
        at org.apache.cxf.bus.extension.Extension.tryClass(Extension.java:183)
at org.apache.cxf.bus.extension.Extension.getClassObject(Extension.java:199)
at org.apache.cxf.bus.extension.ExtensionManagerImpl.activateAllByType(ExtensionManagerImpl.java:144)
at org.apache.cxf.bus.extension.ExtensionManagerBus.<init>(ExtensionManagerBus.java:180)
at org.apache.cxf.bus.extension.ExtensionManagerBus.<init>(ExtensionManagerBus.java:192)
at org.apache.cxf.bus.spring.SpringBus.<init>(SpringBus.java:45)
... 5 more
Caused by: java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.cxf.bus.extension.Extension.tryClass(Extension.java:164)
... 10 more

这是我的BuildConfig的片段:

    compile ":ws-client:1.0"
    compile ":cxf-client:2.1.1"
    compile ":cxf:2.1.1"

我使用grails war构建war文件并将其部署在Tomcat服务器上 我已经检查了Tomcat服务器上项目的WEB-INF/lib文件夹,并且有jar:

cxf-bundle-2.2.4.jar
cxf-core-3.0.4.jar
cxf-rt-bindings-soap-3.0.4.jar
cxf-rt-bindings-xml-3.0.4.jar 
cxf-rt-databinding-jaxb-3.0.4.jar
cxf-rt-frontend-jaxrs-3.0.4.jar
cxf-rt-frontend-jaxws-3.0.4.jar
cxf-rt-frontend-simple-3.0.4.jar
cxf-rt-security-3.0.4.jar
cxf-rt-transports-http-3.0.4.jar
cxf-rt-ws-addr-3.0.4.jar
cxf-rt-wsdl-3.0.4.jar
cxf-rt-ws-policy-3.0.4.jar
cxf-rt-ws-security-3.0.4.jar
cxf-tools-common-3.0.4.jar
cxf-tools-validator-3.0.4.jar
cxf-tools-wsdlto-core-3.0.4.jar
cxf-tools-wsdlto-databinding-jaxb-3.0.4.jar
cxf-tools-wsdlto-frontend-jaxws-3.0.4.jar

为什么我在Tomcat服务器上出现此错误?

1 个答案:

答案 0 :(得分:1)

我有同样的问题,我花了很长时间才弄明白。有些人还在SO上发布了这个问题:

source code

cxf-failing-with-incompatibleclasschangeerror-exception-on-unit-test

AssertionBuilderRegistry加载失败,因为它是一个接口并扩展了AssertionBuilderFactory,而在较旧版本的neethi库中,AssertionBuilderFactory被定义为具体类。因此抛出了IncompatibleClassChangeError。

关于IncompatibleClassChangeError的原因:

could-not-load-extension-class-org-apache-cxf-ws-policy-assertionbuilderregistry

总之,您需要升级neethi库版本。