Cxf jaxb 2.0 API jar is being loaded compatibility

Source: Internet
Author: User
Apache cxf is an open-source services framework that helps you build and develop services like JAX-WS using frontend programming APIs. These services can support multiple protocols, such as soap, XML/HTTP, restful HTTP, or CORBA, and can run on multiple transmission protocols, such as HTTP, JMS, or jbi, cxf greatly simplifies the creation of services and inherits the xfire tradition.
Spring for seamless integration. A classic version problem occurs during the deployment of cxf, namely java. Lang. linkageerror: jaxb 2.0 API jar is being loaded. The detailed error is roughly as follows:
Java. Lang. illegalstateexception: failed to load applicationcontext At org. springframework. Test. Context. testcontext. getapplicationcontext (testcontext. Java: 203) At org. springframework. Test. Context. Support. dependencyinjectiontestexecutionlistener. injectdependencies (dependencyinjectiontestexecutionlistener. Java: 109) At org. springframework. Test. Context. Support. dependencyinjectiontestexecutionlistener. preparetestinstance (dependencyinjectiontestexecutionlistener. Java: 75) At org. springframework. Test. Context. testcontextmanager. preparetestinstance (testcontextmanager. Java: 255) At org. springframework. Test. Context. junit4.springjunit4classrunner. createtest (springjunit4classrunner. Java: 93) At org. springframework. Test. Context. junit4.springjunit4classrunner. invoketestmethod (springjunit4classrunner. Java: 130) At org. JUnit. Internal. Runners. junit4classrunner. runmethods (junit4classrunner. Java: 51) At org. JUnit. Internal. Runners. junit4classrunner $ 1.run( junit4classrunner. Java: 44) At org. JUnit. Internal. Runners. classroadie. rununprotected (classroadie. Java: 27) At org. JUnit. Internal. Runners. classroadie. runprotected (classroadie. Java: 37) At org. JUnit. Internal. Runners. junit4classrunner. Run (junit4classrunner. Java: 42) At org. JUnit. Runner. junitcore. Run (junitcore. Java: 130) At com.intellij.rt.exe cution. JUnit. junitstarter. Main (junitstarter. Java: 62) Caused by: Org. springframework. beans. factory. beancreationexception: Error creating bean with name 'org. apache. cxf. WSDL. wsdlmanager 'defined in class path resource [META-INF/cxf. XML]: instantiation of bean failed; Nested exception is Org. springframework. beans. beaninstantiationexception:
Cocould not instantiate Bean class [Org. apache. cxf. wsdl11.wsdlmanagerimpl]: constructor threw exception; Nested exception is Java. lang. linkageerror: jaxb 2.0 API jar is being loaded (from jar: file:/D: /Works/sources/projects/biap/trunk/biap-APP/webroot/WEB-INF/lib/javaee. jar! /Javax/XML/bind/annotation/XMLSCHEMA. Class ),
But this RI (from jar: file:/D:/Works/sources/projects/biap/trunk/biap-APP/webroot/WEB-INF/lib/jaxb-impl-2.1.7.jar! /COM/Sun/XML/bind/v2/model/impl/modelbuilder. Class) requires jaxb 2.1 API jar. At org. springframework. Beans. Factory. Support. abstractautowirecapablebeanfactory. instantiatebean (abstractautowirecapablebeanfactory. Java: 917) At org. springframework. Beans. Factory. Support. abstractautowirecapablebeanfactory. createbeaninstance (abstractautowirecapablebeanfactory. Java: 873) At org. springframework. Beans. Factory. Support. abstractautowirecapablebeanfactory. docreatebean (abstractautowirecapablebeanfactory. Java: 514) At org. springframework. Beans. Factory. Support. abstractautowirecapablebeanfactory $ 1.run( abstractautowirecapablebeanfactory. Java: 485) At java. Security. accesscontroller. doprivileged (native method) At org. springframework. Beans. Factory. Support. abstractautowirecapablebeanfactory. createbean (abstractautowirecapablebeanfactory. Java: 455) At org. springframework. Beans. Factory. Support. abstractbeanfactory $1. GetObject (abstractbeanfactory. Java: 251) At org. springframework. Beans. Factory. Support. defaultsingletonbeanregistry. getsingleton (defaultsingletonbeanregistry. Java: 169) At org. springframework. Beans. Factory. Support. abstractbeanfactory. getbean (abstractbeanfactory. Java: 248) At org. springframework. Beans. Factory. Support. abstractbeanfactory. getbean (abstractbeanfactory. Java: 170) At org. springframework. Beans. Factory. Support. defaultlistablebeanfactory. preinstantiatesingletons (defaultlistablebeanfactory. Java: 413) At org. springframework. Context. Support. abstractapplicationcontext. finispolicanfactoryinitialization (abstractapplicationcontext. Java: 735) At org. springframework. Context. Support. abstractapplicationcontext. Refresh (abstractapplicationcontext. Java: 369) At org. springframework. Test. Context. Support. abstractgenericcontextloader. loadcontext (abstractgenericcontextloader. Java: 84) At org. springframework. Test. Context. Support. abstractgenericcontextloader. loadcontext (abstractgenericcontextloader. Java: 42) At org. springframework. Test. Context. testcontext. loadapplicationcontext (testcontext. Java: 173) At org. springframework. Test. Context. testcontext. getapplicationcontext (testcontext. Java: 199) ... 14 more Caused by: Org. springframework. beans. beaninstantiationexception: cocould not instantiate Bean class [Org. apache. cxf. wsdl11.wsdlmanagerimpl]: constructor threw exception; Nested exception is Java. lang. linkageerror: jaxb 2.0 API jar is being loaded (from jar: file:/D: /Works/sources/projects/biap/trunk/biap-APP/webroot/WEB-INF/lib/javaee. jar! /Javax/XML/bind/annotation/XMLSCHEMA. Class ),
But this RI (from jar: file:/D:/Works/sources/projects/biap/trunk/biap-APP/webroot/WEB-INF/lib/jaxb-impl-2.1.7.jar! /COM/Sun/XML/bind/v2/model/impl/modelbuilder. Class) requires jaxb 2.1 API jar. At org. springframework. Beans. beanutils. instantiateclass (beanutils. Java: 98) At org. springframework. Beans. Factory. Support. simpleinstantiationstrategy. instantiate (simpleinstantiationstrategy. Java: 61) At org. springframework. Beans. Factory. Support. abstractautowirecapablebeanfactory. instantiatebean (abstractautowirecapablebeanfactory. Java: 911) ... 30 more Caused by: Java. lang. linkageerror: jaxb 2.0 API jar is being loaded (from jar: file:/D: /Works/sources/projects/biap/trunk/biap-APP/webroot/WEB-INF/lib/javaee. jar! /Javax/XML/bind/annotation/XMLSCHEMA. class), but this RI (from jar: file:/D:/Works/sources/projects/biap/trunk/biap-APP/webroot/WEB-INF/lib/jaxb-impl-2.1.7.jar! /COM/Sun/XML/bind/v2/model/impl/modelbuilder. Class)
Requires jaxb 2.1 API jar. At com. Sun. xml. Bind. v2.model. impl. modelbuilder. <clinit> (modelbuilder. Java: 173) At com. Sun. xml. Bind. v2.runtime. jaxbcontextimpl. gettypeinfoset (jaxbcontextimpl. Java: 422) At com. Sun. xml. Bind. v2.runtime. jaxbcontextimpl. <init> (jaxbcontextimpl. Java: 286) At com. Sun. xml. Bind. v2.contextfactory. createcontext (contextfactory. Java: 139) At com. Sun. xml. Bind. v2.contextfactory. createcontext (contextfactory. Java: 117) At com. Sun. xml. Bind. v2.contextfactory. createcontext (contextfactory. Java: 188) At sun. Reflect. nativemethodaccessorimpl. invoke0 (native method) At sun. Reflect. nativemethodaccessorimpl. Invoke (nativemethodaccessorimpl. Java: 39) At sun. Reflect. delegatingmethodaccessorimpl. Invoke (delegatingmethodaccessorimpl. Java: 25) At javax. xml. Bind. contextfinder. newinstance (contextfinder. Java: 132) At javax. xml. Bind. contextfinder. Find (contextfinder. Java: 286) At javax. xml. Bind. jaxbcontext. newinstance (jaxbcontext. Java: 372) At javax. xml. Bind. jaxbcontext. newinstance (jaxbcontext. Java: 337) At org. Apache. cxf. WSDL. jaxbextensionhelper. createjaxbcontext (jaxbextensionhelper. Java: 196) At org. Apache. cxf. WSDL. jaxbextensionhelper. getjaxbcontext (jaxbextensionhelper. Java: 183) At org. Apache. cxf. WSDL. jaxbextensionhelper. addextensions (jaxbextensionhelper. Java: 168) At org. Apache. cxf. WSDL. jaxbextensionhelper. addextensions (jaxbextensionhelper. Java: 88) At org. Apache. cxf. wsdl11.wsdlmanagerimpl. registerinitialextensions (wsdlmanagerimpl. Java: 241) At org. Apache. cxf. wsdl11.wsdlmanagerimpl. registerinitialextensions (wsdlmanagerimpl. Java: 221) At org. Apache. cxf. wsdl11.wsdlmanagerimpl. <init> (wsdlmanagerimpl. Java: 110) At sun. Reflect. nativeconstructoraccessorimpl. newinstance0 (native method) At sun. Reflect. nativeconstruct%cessorimpl. newinstance (nativeconstruct%cessorimpl. Java: 39) At sun. Reflect. delegatingconstruct%cessorimpl. newinstance (delegatingconstruct%cessorimpl. Java: 27) At java. Lang. Reflect. constructor. newinstance (constructor. Java: 494) At org. springframework. Beans. beanutils. instantiateclass (beanutils. Java: 83) ... 32 more
This problem occurs because a jaxb2.0 interface already exists in the deployment environment. I found in the cxf version number that cxf2.0.x supports the jaxb2.0 interface, but in Versions later than cxf2.1.x, the jaxb version has been upgraded to 2.1, but neither jdk1.5 nor jdk1.6 has been upgraded. Solution. With cxf2.1.x or later versions of friends, to solve the jaxb2.0 version upgrade problem, from the root problem to find out, you can use the following method: jaxb-impl-2.1.7 Java COM. sun. XML. BIND. v2.model. impl. javax. XML. BIND. annotation. the location () method of the XMLSCHEMA interface, but this method is not provided in javaee, which is provided in the jaxb-api-2.1. Solution: In the deployment environment, check whether Java EE is available under your project Lib. jar. If yes, delete it and get javaee from the container load. In this way, the project will first read the jaxb2.1 interface on which cxf2.1.x depends. Some deployment environments may be normal, because javaee is loaded after jaxb. If this problem occurs, try my solution.
OriginalArticle, If reproduced, please mark the author: Tian Wen csdn address: http://blog.csdn.net/tiwen818

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.