问题描述
我的开发环境中一直出现以下错误。我使用
I keep getting the following error in my dev environment. I use
- Eclipse Mars 4.5.1
- Oracle JDK 1.7(build 1.7.0_79-b15 )或1.8(build 1.8.0_65-b17)
- 运行代码的Apache Ant以及运行代码的Eclipse
-
Ivy用于依赖关系管理,其中包含以下内容
- Eclipse Mars 4.5.1
- Oracle JDK 1.7 (build 1.7.0_79-b15) or 1.8 (build 1.8.0_65-b17)
- Apache Ant to run the code as well as Eclipse to run the code
Ivy for dependency management where I include the following
<!-- 3rd party dependencies -->
<dependency org="log4j" name="log4j" rev="1.2.16" conf="test->default"/>
<dependency org="commons-httpclient" name="commons-httpclient" rev="3.1" conf="compile->default"/>
<dependency org="org.jvnet.jaxb2_commons" name="jaxb2-basics-runtime" rev="0.6.4" conf="default->runtime"/>
<dependency org="org.jvnet.jaxb2_commons" name="jaxb2-basics-tools" rev="0.6.4" conf="default->runtime"/>
<dependency org="org.jvnet.jaxb2_commons" name="jaxb2-basics" rev="0.6.4" conf="default->runtime"/>
我看过其他帖子主题,但他们的答案没有多大帮助。我尝试使用jaxb.properties,但没有改变行为。
I've seen the other posts on this topic but their answers don't help much. I tried using a jaxb.properties but that did not change the behavior.
javax.xml.bind.context.factory=com.sun.tools.xjc.runtime.JAXBContextFactory
Exception in thread "main" javax.xml.bind.JAXBException
- with linked exception:
[java.lang.ClassNotFoundException: com.ibm.xml.xlxp2.jaxb.JAXBContextFactory]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:227)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:432)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:637)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
at com.acme.merge.util.ProjectsInformation.unMarshal(ProjectsInformation.java:24)
at com.acme.merge.controller.MergeController.main(MergeController.java:44)
Caused by: java.lang.ClassNotFoundException: com.ibm.xml.xlxp2.jaxb.JAXBContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at javax.xml.bind.ContextFinder.safeLoadClass(ContextFinder.java:563)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:225)
... 5 more
我在俯瞰什么?
推荐答案
我找到了根本原因。我在ivy中的一些依赖项具有传递依赖项,这些依赖项引入了一些IBM WS库。这些库覆盖我的设置并强制使用 com.ibm.xml.xlxp2.jaxb.JAXBContextFactory
。排除这些解决了我的问题。
I found the root cause. Some of my dependencies in ivy have transitive dependencies that bring in some IBM WS libraries. These libraries override my settings and force the use of com.ibm.xml.xlxp2.jaxb.JAXBContextFactory
. Excluding these resolved my issue.
冲突的jar来自包 com.ibm.ws
并被称为 runtime.jar
。
The conflicting jar is from package com.ibm.ws
and is called runtime.jar
.
这篇关于JAXBContextFactory地狱 - java.lang.ClassNotFoundException:com.ibm.xml.xlxp2.jaxb.JAXBContextFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!