java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloa

阅读更多

Exception in thread "main" java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/D:/project/testWebService/WebRoot/WEB-INF/lib/jaxb-impl-2.1.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/)
 at com.sun.xml.bind.v2.model.impl.ModelBuilder.(ModelBuilder.java:136)
 at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:406)
 at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:270)
 at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:103)
 at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:81)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:210)
 at javax.xml.bind.ContextFinder.find(ContextFinder.java:368)
 at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
 at org.apache.cxf.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:260)
 at org.apache.cxf.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:169)
 at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:418)
 at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:290)
 at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
 at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:444)
 at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:682)
 at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:507)
 at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:241)
 at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:202)
 at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
 at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:90)
 at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:153)
 at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:151)
 at com.gary.test.ws.test.TestGreetingService.main(TestGreetingService.java:21)

 

 

 

网上有一些方法:

错误的原因就是:项目中集成webservice(CXF)时,包冲突了

解决方式:

1)、下载jaxb-api-2.1.jar、jaxws-api-2.1.jar两包

2)、将以上两个文件放到下面路径中:

A、 java项目直接打印System.out.println(System.getProperty("java.endorsed.dirs"));获得路径,如果没有,自建

B、java web 项目要用一个可以正常启动的web项目(当然没用到jaxb的web项目),打印System.out.println(System.getProperty("java.endorsed.dirs"));获得路径,如果没有,自建

之后,重启myeclipse

4、按照上面的操作,你很有可能已经解决问题了,如果你还没有解决问题,进行如下操作:

 

将JRE运行环境调整到最上面,主要是为了刚刚添加的两个jar文件先加载,(endorsed)

这个很重理!

 

http://blog.csdn.net/javaloveiphone/article/details/8693133

 

 

你可能感兴趣的:(java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloa)