链接错误 JAXB 2.0 -> 2.1(雄猫)
当我尝试访问在 tomcat 中运行的 web 服务时,出现此错误。
由以下原因引起:java.lang.LinkageError:JAXB 2.0 API 正在从引导类加载器加载,但是此 RI(来自 jar:file:/C:/software/tomcat6/webapps/messaging/WEB-INF/lib/ jaxb-impl-2.1.5.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) 需要 2.1 API。 使用认可的目录机制将 jaxb-api.jar 放置在引导类加载器中。 (参见http://java.sun.com/j2se/1.5 .0/docs/guide/standards/)
我用谷歌搜索了错误并做了什么应该解决它(我将 jaxb-api.jar,版本 2.1 放在 JDK/lib/endorsed 和 JDK/jre/lib/endorsed )但似乎没有任何效果。
我之前没有,也不知道有什么变化。 我使用 JDK 6u10。
I'm getting this error when trying to access my webservice running inside tomcat.
Caused by: java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/C:/software/tomcat6/webapps/messaging/WEB-INF/lib/jaxb-impl-2.1.5.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/)
I googled for the error and did what should solve it (I put jaxb-api.jar, version 2.1 in JDK/lib/endorsed and JDK/jre/lib/endorsed) but it doesn't appear to have any effect.
I didn't have it before, and I'm not sure what was changed. I use JDK 6u10.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Java 6u10 包含 JAXB 2.1,因此根本不需要包含它(从 6u4 开始就包含了)。
现在看来,Web 应用程序中包含的 JAXB 与 JRE 附带的捆绑 JAXB 之间存在冲突。 您可以尝试从 web 应用程序 (
C:/software/tomcat6/webapps/messaging/WEB-INF/lib/jaxb-impl-2.1.5.jar
) 中删除 JAXB jar,并依赖于构建的- 在版本中。Java 6u10 includes JAXB 2.1, so there is no need to include it at all (it has been included since 6u4).
Right now it looks like you have a conflict between JAXB included with a webapp and the bundled JAXB that comes with JRE. You could try removing the JAXB jar from your webapp (
C:/software/tomcat6/webapps/messaging/WEB-INF/lib/jaxb-impl-2.1.5.jar
) and rely on the built-in version.推荐的方法是定义 JAVA_ENDORSED_DIRS 环境变量。 然后 Tomcat 将使用这个 Java 属性:
为了加载认可的 jar。 因此,创建一个文件夹,将 jaxb-api.jar v2.1 放在那里并定义环境变量以指向该文件夹。
这比使用全局认可目录更好,因为它不会影响整个 JVM,并且在更新 JRE 时您不必重复该过程。
The recommended way is to define the JAVA_ENDORSED_DIRS environmental variable. Then Tomcat will use this Java property:
in order to load the endorsed jars. So, create a folder, put jaxb-api.jar v2.1 there and define the environmental variable to point at that folder.
This is better than using the global endorsed directory, because it doesn't affect the whole JVM and you don't have to repeat the process, when the JRE is updated.
$JAVA_HOME/jre/lib/ext 目录中是否有 jaxb jar? 这是引导加载程序的定义:
(取自此处)
请搜索所有系统中存在 jaxb jar 的位置(至少是 jaxb-api 和 jaxb-impl),并确保它们位于 Web 应用程序的 WEB-INF/lib 目录中或 tomcat 的 lib 目录中。
Is it possible you have the jaxb jars in the $JAVA_HOME/jre/lib/ext directory? Here is the definition of the bootstrap loader:
(Taken form here)
Please search for all the places where you have the jaxb jars in the system (at least jaxb-api and jaxb-impl) and make sure that they are in either the WEB-INF/lib directory of your web application or in the lib directory of the tomcat.