CXF中jaxb-api.jar、jaxws-api.jar与jdk1.6不兼容问题
服务器是tomcat6,在cxf-2.3.10中的:jaxb-api-2.2.3.jar jaxb-impl-2.2.4-1.jar 在jdk1.6中不兼容的问题,报错如下:
Caused by: java.lang.LinkageError: JAXB 2.1 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/xxxx/app/WEB-INF/lib/jaxb-impl-2.2.4-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:177)
?at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:450)
原因是:需要jaxb 2.1,却加载了2.0,因为jdk1.6自带jaxb 2.0造成的,解决的办法是在D:\tomcat6下加入endorsed文件夹,
把JAXB-API-2.1.jar和jaxws-api.jar放入endorsed文件夹中。
也可以通过System.out.println(System.getProperty("java.endorsed.dirs")); 来查看你的endorsed目录的位置。