我有一个JAXB对象,我可以解组很好.但是,如果我添加一个使用@XmlAnyElement注释的Element []字段,则在尝试解组时会抛出:
java.lang.IllegalStateException: You are running with invalid JAXP api or implementation. JAXP api/implementation of version 1.3.1 (included in JDK6) or higher is required. In case you are using ant,make sure ant 1.7.0 or higher is used – older versions of ant contain JAXP api/impl version 1.2 (in xml-apis.jar). If you want to keep using older ant versions,you have to configure it to use higher the JAXP api/impl versions.
这是通过我通过Eclipse插件运行的TestNG测试运行的.我正在运行1.6 JDK并配置maven以排除旧版本的xml-apis jar但是我似乎无法让它工作.我假设我仍然从某个地方拾取不兼容的库版本,但不知道从哪里来.
直接通过Eclipse运行我得到:
29-Aug-2013 10:04:08 com.sun.xml.bind.v2.util.XmlFactory createTransformerFactory SEVERE: null java.lang.AbstractMethodError: javax.xml.transform.TransformerFactory.setFeature(Ljava/lang/String;Z)V at com.sun.xml.bind.v2.util.XmlFactory.createTransformerFactory(XmlFactory.java:155) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.createTransformerHandler(JAXBContextImpl.java:747) at com.sun.xml.bind.v2.runtime.unmarshaller.Domloader$State.<init>(Domloader.java:75) at com.sun.xml.bind.v2.runtime.unmarshaller.Domloader.startElement(Domloader.java:118) at com.sun.xml.bind.v2.runtime.unmarshaller.ProxyLoader.startElement(ProxyLoader.java:60) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:501) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:480) at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:150) at org.apache.xerces.parsers.AbstractSAXParser.startElement(UnkNown Source) at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(UnkNown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(UnkNown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentdispatcher.dispatch(UnkNown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(UnkNown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(UnkNown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(UnkNown Source) at org.apache.xerces.parsers.XMLParser.parse(UnkNown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(UnkNown Source) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:218) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:190) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:184) at com.gtspt.vrs.parser.AbstractParserTest.unmarshal(AbstractParserTest.java:33) at com.gtspt.vrs.parser.AbstractParserTest.testParser(AbstractParserTest.java:26) at com.gtspt.vrs.parser.TestResultsParser.testParser(TestResultsParser.java:17) at com.gtspt.vrs.parser.Test.main(Test.java:16)
解决方法
看起来这个问题是由旧版本的Xalan造成的.从JDK 5开始,似乎需要最低版本2.7.0.另一个库提供了旧版本,因此我将其从Maven构建中排除,现在一切看起来都很好.
原文地址:https://www.jb51.cc/java/127207.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。