Hiberate - JAXB compatibility issue


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:


Unmarshalling code:

  // Unmarshall and extract the Inbound XML from EDI
    InputStream inboundXmlStream = new ByteArrayInputStream(
    JAXBContext jaxbContext = JAXBContext.newInstance(PartyDataPublishType.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
    PartyDataPublishType ibXmlUp = (PartyDataPublishType) jaxbUnmarshaller

      String inboundXmlPubDttm = dateFormat

Understand. Let me try this in work area.

not working in my section.

I would start by looking at the dependency differences between when you use 5.3.x.Final and 5.4.x.Final to see if there is an obvious reason why you’re observing different behavior.

When you say “not working” , are you able to reproduce my problem?

Will check and get back to you.

I ran a Maven Site report to determine the dependencies and for Hibernate 5.4.4 seems to have a transient dependency on JAXB. How would this interfere?

Chances are the commits to hibernate-core.gradle are the reason.
I would take a look at HHH-12946 for details on the changes shown there.

In short, a great deal of work has been done in the 5.4 branch to stablize Hibernate to not only work on JDK8, but also on JDK9 and beyond.

As for the transitive dependency, as long as you don’t have mixed versions on the class-path, it ultimately should not; unless the underlying dependency’s behavior changed from 2.2.11 (which was what 5.3 used) to 2.3.1 (which is what 5.4 uses).

One thing you could try is locking the dependencies for JAXB back to 2.2.11 when using Hibernate 5.4 and see if that resolves your issue if you can’t find the reason why 2.3.1 isn’t working for you. I haven’t looked at the recent changes to see whether that could introduce some incompatibility, but its worth a shot in the least.