AXIS-JAXB Unmarshal not working with any JDK except jdk 1.8.077

不问归期 提交于 2019-12-14 02:09:40

问题


I have followed the below procedures:

  1. Generated client files in eclipse using WSDL (Apache Axis 1).
  2. Using JAXB to unmarshal the request XML and then call the webservice.

If I use JDK 1.8.077 then the XML is getting parsed successfully. If I use any other JDK like version 1.8.102 or 1.8.112 JAXB is unable to parse properly and returns a null value for the element.

Could anyone please suggest me the issue here?


回答1:


I can confirm the same faulty behavior with 1.8.111, after downgrading to 1.8.74 JAXB was able to parse properly.

Version 1.8.111:

JAXBContext.createUnmarshaller().unmarshal(new StreamSource(...), MyType.class).getValue()

returns a null




回答2:


One of the possible reason for the issue is with the parser expecting the code to provide support for XML namespace with later versions of JDK 1.8.

In case you are using the SAX based parser to parse the XML document, make sure you set the namespaceAware API to true

final SAXParserFactory sax = SAXParserFactory.newInstance(); sax.setNamespaceAware(true);

By default the value is set as false

I faced the same issue using the JDK version 1.8.121 & 1.8.131 with the SAX based parser and the issue got resolved by simply setting the value true for namespaceAware API for SAXParserFactory instance.

NOTE: The JAXB classes were generated from eclipse



来源:https://stackoverflow.com/questions/41608667/axis-jaxb-unmarshal-not-working-with-any-jdk-except-jdk-1-8-077

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!