我正在尝试使用 XPath 通过EclipseLink JAXB (MOXy)映射 XML 文档。但是当 XML 包含 CDATA 标记时会遇到问题示例:
<![CDATA[Jill's Box Company]]>
我正在使用 eclipselink-2.3.0 jar 在我的应用程序中获取 XPath 映射。为了让 JAXB 使用这个实现,我正在创建一个jaxb.properties
包含以下内容的文件:
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
XPath 只能以这种方式工作,否则应用程序甚至不会获取注释@XmlPath
。
现在,在通过 unmarshaller 方法运行 XML 时,它会抛出一个空指针错误,如下所示:
java.lang.NullPointerException
at org.eclipse.persistence.oxm.record.UnmarshalRecord.startCDATA(UnmarshalRecord.java:1035)
at org.eclipse.persistence.internal.oxm.record.XMLReader$LexicalHandlerWrapper.startCDATA(XMLReader.java:226)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startCDATA(AbstractSAXParser.java:625)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:487)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:133)
at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:173)
at org.eclipse.persistence.internal.oxm.record.XMLReader.parse(XMLReader.java:147)
at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:713)
at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:286)
at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:260)
at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:505)
at org.eclipse.persistence.oxm.XMLUnmarshaller.unmarshal(XMLUnmarshaller.java:594)
at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:269)
at com.jbhunt.lib.mgintegrationutils.utils.JAXBUtils.unmarshal(JAXBUtils.java:67)
at com.jbhunt.biz.mgarListener.mq.converter.MgarListenerMQMessageParser.getMasterARStagingVo(MgarListenerMQMessageParser.java:51)
at com.jbhunt.biz.mgarListener.mq.MgarListenerMessageConsumerImpl.onMessage(MgarListenerMessageConsumerImpl.java:62)
at com.jbhunt.biz.mgarListener.mq.JMSMessageProcessor.receiveAndProcessMessage(JMSMessageProcessor.java:106)
at com.jbhunt.biz.mgarListener.thread.MessageProcessorThread.run(MessageProcessorThread.java:46)
at java.lang.Thread.run(Thread.java:662)