我在尝试运行使用jaxb2插件执行JAXB codegen的maven构建时遇到了一个奇怪的问题(请参阅下面的stacktrace).我能想到的最好的是DTMManager的一些实现,它是从与xalan-2.7.1中的JAR不同的JAR加载的.但是,我已经验证了用于运行jaxb:generate目标的类路径只有一个包含DTMManager或DTMManagerDefault的xalan-2.7.1.jar – 所以我不知道其他可能会遇到什么.
最后一个数据点:我们的构建指定了一个’快照’配置文件,它实际上只用于JAR up源(使用maven-source-plugin)并将它们作为工件发布.除了默认情况外,仅在指定此配置文件时才会出现上述故障情况.
我在Linux x64(Fedora 13)上使用Sun的64位JDK 1.6.0_21上运行的Maven 2.2.1 – 请参阅下面的’mvn -v’信息的堆栈跟踪.
关于问题可能是什么和/或如何进行调试的任何想法?这让我在过去几天感到悲痛,现在阻止了进展:(
java.lang.ClassCastException: org.apache.xml.dtm.ref.DTMManagerDefault cannot be cast to org.apache.xml.dtm.DTMManager at org.apache.xml.dtm.DTMManager.newInstance(DTMManager.java:137) at org.apache.xpath.XPathContext.<init>(XPathContext.java:102) at org.apache.xpath.jaxp.XPathImpl.eval(XPathImpl.java:207) at org.apache.xpath.jaxp.XPathImpl.evaluate(XPathImpl.java:281) at com.sun.tools.xjc.reader.internalizer.Internalizer.buildTargetNodeMap(Internalizer.java:224) at com.sun.tools.xjc.reader.internalizer.Internalizer.buildTargetNodeMap(Internalizer.java:289) at com.sun.tools.xjc.reader.internalizer.Internalizer.transform(Internalizer.java:134) at com.sun.tools.xjc.reader.internalizer.Internalizer.transform(Internalizer.java:96) at com.sun.tools.xjc.reader.internalizer.DOMForest.transform(DOMForest.java:448) at com.sun.tools.xjc.ModelLoader.buildDOMForest(ModelLoader.java:342) at com.sun.tools.xjc.ModelLoader.loadXMLSchema(ModelLoader.java:374) at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:167) at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:113) at org.jvnet.jaxb2.maven2.XJC2Mojo.runXJC(XJC2Mojo.java:1119) at org.jvnet.jaxb2.maven2.XJC2Mojo.execute(XJC2Mojo.java:720) ...
mvn -v:
# mvn -v Apache Maven 2.2.1 (r801777; 2009-08-06 14:16:01-0500) Java version: 1.6.0_21 Java home: /usr/java/jdk1.6.0_21/jre Default locale: en_US,platform encoding: UTF-8 OS name: "linux" version: "2.6.33.3-85.fc13.x86_64" arch: "amd64" Family: "unix"
解决方法
解决方案是在类路径中搜索Xalan和xercesImpl的所有依赖项.应排除这些依赖关系.
更新
我找到了这样的答案 – 见http://www.mail-archive.com/dev@qpid.apache.org/msg07295.html
Had a look at this closely and figured it was due to a classpath class due to Sun bundling an older version of Xalan jar. I have disabled this test until we come up with a decent solution. Rajith