---
title: "CXF与jdk1.6兼容问题"
author: "cheneyph"
date: "2011-03-24T22:18:58Z"
tags: []
categories: ["企业架构"]
slug: "cxf-jdk1-6"
draft: false
lastmod: "2011-03-24T22:18:58Z"
id: 974641
url: "https://cheneyph.iteye.com/blog/974641"
---

Context initialization failed  
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.cxf.wsdl.WSDLManager' defined in class path resource \[META-INF/cxf/cxf.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class \[org.apache.cxf.wsdl11.WSDLManagerImpl]: Constructor threw exception; nested exception is java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/E:/apache-tomcat-6.0.14/webapps/webService1/WEB-INF/lib/jaxb-impl-2.1.7.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.1 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader. (See  [http://java.sun.com/j2se/1.5.0/docs/guide/standards/](http://java.sun.com/j2se/1.5.0/docs/guide/standards/) )  
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class \[org.apache.cxf.wsdl11.WSDLManagerImpl]: Constructor threw exception; nested exception is java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/E:/apache-tomcat-6.0.14/webapps/webService1/WEB-INF/lib/jaxb-impl-2.1.7.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.1 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader. (See  [http://java.sun.com/j2se/1.5.0/docs/guide/standards/](http://java.sun.com/j2se/1.5.0/docs/guide/standards/) )  
Caused by: java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/E:/apache-tomcat-6.0.14/webapps/webService1/WEB-INF/lib/jaxb-impl-2.1.7.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.1 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader. (See[http://java.sun.com/j2se/1.5.0/docs/guide/standards/](http://java.sun.com/j2se/1.5.0/docs/guide/standards/) )

CXF框架，因为它能和Spring很好的集成。然后看了  [http://www.iteye.com/topic/305642](http://lxj8495138.iteye.com/topic/305642)  这位仁兄的文章，着手开始实现第一个简单的程序，然而，在完全按照视频要求完成后，控制台总是报错，说什么

 

nested exception is java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI needs 2.1 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader. (See [http://java.sun.com/j2se/1.5.0/docs/guide/standards/](http://java.sun.com/j2se/1.5.0/docs/guide/standards/) )

 

按字面意思就是现在使用的是JAXB 2.0的API，但是需要2.1的API。看了要求去看的网页，然后又在网上找寻了很长时间，问题终于被解决。

 如果看的懂E文的话，可以去看看这篇文章

[http://nwangwei.spaces.live.com/Blog/cns!3A3D02B743E87051!240.entry](http://nwangwei.spaces.live.com/Blog/cns!3A3D02B743E87051!240.entry)

 

只要按照第一种方法就行了

One way to fix this is to copy  `jaxws-api.jar`   and  `jaxb-api.jar`   into JRE endorsed directory, which is  `$JAVA_HOME/lib/endorsed`   (or`$JDK_HOME/jre/lib/endorsed` )

 

首先在JDK的lib目录下新建endorsed目录（如果存在就不需要新建了）

然后把jaxws-api.jar 和jaxb-api.jar 拷贝endorsed目录下，问题解决。

 

 

或更新到jdk1.6u11就ok了！