Hello,
I have a Java 8/Maven automation framework project for parsing XML using JAXB and comparing the data in a DB using JPA/Hibernate 5.4.4.Final.
I generated the JAXB classes using the xsd schema and the unmarshalling and comparison works fine when using Hibernate 5.3.11.Final. However, the unmarshalling using JAXB returns null when using Hibernate 5.4.4.Final.
I am using Java 8 and hence I did not need explicit dependencies for JAXB. However, I do not understand why I get this issue. I noticed that adding explicit dependencies also does not fix it.
Why is there a dependency for JAXB on Hibernate? And why is the version 5.4.x having this issue? How do I resolve this?
pom.xml dependencies:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.4.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>5.4.4.Final</version>
</dependency>
Unmarshalling code:
// Unmarshall and extract the Inbound XML from EDI
InputStream inboundXmlStream = new ByteArrayInputStream(
ScenarioObject.getInstance().getInboundXml()
.replace("http://www.fanniemae.com/enterprisedata/dataservices/party/v3.x",
"http://www.fanniemae.com/enterprisedata/core/subjectarea/party/v3.x")
.getBytes(StandardCharsets.UTF_8));
JAXBContext jaxbContext = JAXBContext.newInstance(PartyDataPublishType.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
PartyDataPublishType ibXmlUp = (PartyDataPublishType) jaxbUnmarshaller
.unmarshal(inboundXmlStream);
String inboundXmlPubDttm = dateFormat
.format(ibXmlUp.getPublishHeader().getPublishTimestamp().toGregorianCalendar().getTime());