我正在尝试使用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方法时,它会抛出一个空指针错误,如下所示:
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)
答案 0 :(得分:0)
<强>更新强>
嗨Blaise,我将eclipse版本更新为2.4.1并解决了问题 我面临的CDATA问题。它现在好了。
我很高兴听到现在一切正常。下面是一篇关于EclipseLink 2.4中MOXy新功能的文章:
由于您使用的是EclipseLink 2.3.0,我相信您遇到了以下在EclipseLink 2.3.1中修复的错误。
EclipseLink目前的版本为2.4.1,如果可以的话,我建议升级到: