JDK6与引入的JAXB 冲突的问题

从svn导入项目,运行报错如下:

Caused by: java.lang.LinkageError: JAXB 2.1 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/D:/workspaces/ddlib/WebRoot/WEB-INF/lib/jaxb-impl-2.2.1.1.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.2 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader. (See http://java.sun.com/j2se/1.6.0/docs/guide/standards/)
	at com.sun.xml.bind.v2.model.impl.ModelBuilder.<clinit>(ModelBuilder.java:173)
	at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:456)
	at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:302)
	at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
	at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
	at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
 

svn环境:jdk1.5+tomcat5

本地环境:jdk1.6+tomcat6

 

上网搜了下原因如下;

在JDK6之后,都自带了JAXB工具,所以在jdk类库与tomcat WEBAPP类库之间,会造成冲突

 

解决办法:

删掉工程中的jaxb-api-2.2.1.jar 包与jaxb-impl-2.2.1.1.jar

 

1.在jdK目录下的jre/lib/中建立endorsed文件夹,

具体是要在哪个目录下,可以通过System.out.println(System.getProperty("java.endorsed.dirs")); 来查看你的endorsed目录的位置。

然后将jaxb-api-2.2.1.jar 包与jaxb-impl-2.2.1.1.jar包拷入endorsed文件夹中,并将%JAVA_HOME%\ jre\lib\endorsed加入classpath

(无效)

 

2.如果是 Tomcat 5.5, 则新建文件路径为 “Tomcat 5.5\common\endorsed” ,如果是 Tomcat 6.0 ,则新建路径为 “Tomcat 6.0\endorsed” 不是在 jdk1.6.0_05\jre\lib\

(解决)

 

 

 

 

 

 

 

你可能感兴趣的:(JAXB)