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

我刚开始搭平台环境时就遇到这个很郁闷的问题:(困扰了好久)

 

我刚开始用的环境是MyEclipse 6.5(完整安装版)+JDK 6 (update 2)+tomcat 6.0,这个环境按理来说应该是比较合适的了,

但是按照这个环境搭建起来之后,不能显示相应的form,会报下面莫名其妙的错误:

 

java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader,
but this RI (from jar:file:/E:/jercy/tomcat6/tomcat6/webapps/helloword/WEB-INF/lib/jaxb-impl.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/)
 com.sun.xml.bind.v2.model.impl.ModelBuilder.<clinit>(ModelBuilder.java:135)
 com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:389)
 com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:253)
 com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:84)
 com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:66)
 com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:132)
 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 java.lang.reflect.Method.invoke(Method.java:597)
 javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:132)
 javax.xml.bind.ContextFinder.find(ContextFinder.java:286)
 javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
 javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
 javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:244)
 com.aisino.platform.util.RsUtil.unmarshall(Unknown Source)
 com.aisino.platform.core.event.ServiceMgr.initialize(Unknown Source)
 com.aisino.platform.core.event.EventRegistor.fireInitEvent(Unknown Source)
 com.aisino.platform.view.Stub.b(Unknown Source)
 com.aisino.platform.view.Stub.initFormByServlet(Unknown Source)
 com.aisino.platform.view.html.HtmlMaker.<init>(Unknown Source)
 com.aisino.platform.view.servlet.InitFormServlet.doShowForm(Unknown Source)
 com.aisino.platform.view.servlet.InitFormServlet.doGet(Unknown Source)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 com.aisino.platform.util.SecurityFilter.doFilter(Unknown Source)

 

从上面的错误中,大概也能看到是jaxb-impl.jar的版本太低了,needs 2.1 API.,所以自己就找2.1的包

 

在网上参考了这个博客,以及上面提供的jar包:

http://lxj8495138.javaeye.com/blog/338384

以及

http://queue19.javaeye.com/blog/418748

 

我按他上面的方法:

        自己测试: jre必须是1.6, tomcat5.5的jdk可以是jdk1.5, jdk和jre下面新建endorsed文件夹,并放入jaxb-api.jar和jaxws-api.jar是没用的, 必须把这两个jar包放入"tomcat5.5/common/endorsed"(没有这个文件夹则新建,如果是 tomcat6.0, 则放在"Tomcat6.0/endorsed"), 特把两个jar共享.. 测试内容: 自制webservices客户端访问jax-ws的webservices服务端 测试环境: myeclipse6.5 tomcat5.5 jre1.6 jdk1.5(可以全是1.6)

但是测试之后都不行。

并且我把最新下载的jar包直接放到项目E:/jercy/tomcat6/tomcat6/webapps/helloword/WEB-INF/lib下还是不行

 

 

我又测试了:jdk6.0.2+MyEclipse 6.5+tomcat5.5

                  jdk6.0.2+MyEclipse 7.5+tomcat6.0

这两种情况都是一样的效果

 

可以肯定是:不是MyEclipse和Tomcat的问题

 

注意:上面得Tomcat完全安装版和精简版都测试了,还是一样的情况,

但是若是使用MyEclipse7.5中自带的Tomcat发布程序不会出错,自己也很纳闷!

 

 

最后的方法:

MyEclipse和Tomcat都重装了不行,就是JDk的问题:

Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader

 

最后更新了JDk到最新的Update17,或者重新安装JDK的版本高的,

再测试就不会出错

你可能感兴趣的:(jdk,tomcat,MyEclipse,api,JAXB,ClassLoader)