Reputation: 1
I try to upgrade a project from java 8 to java 11. During the build process, we generate hibernate static meta model from orm.xml file.
When using a jdk11 for the maven build mvn clean install
. StaticModel class are not generated and "target/generated-sources/annotations" is empty.
With a debug point in org.hibernate.jpamodelgen.xml.JpaDescriptorParser#L153. I manage to retrieve the real error message.
Error message
Implementation of JAXB-API has not been found on module path or classpath.
Ok so its links to the removal of jaxb in Java 11.
I made a simple project to showcase my issue : https://github.com/epi-fr/hibernate-orm-xml-java11
I try several approach to import jaxb during the generation phase. But I didn't manage to generate the static model.
Base on Mkyong article (point 6.3). I managed to go further, i think, but I get this strange error :
New exception message at org.hibernate.jpamodelgen.xml.JpaDescriptorParser#L153.
ClassCastException: attempting to cast jar:file:/home/user/.m2/repository/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar!/javax/xml/bind/JAXBContext.class to jar:file:/home/user/.m2/repository/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar!/javax/xml/bind/JAXBContext.class. Please make sure that you are specifying the proper ClassLoader.
I push my change on the demo project on the branch "try_import_jaxb2.3".
Any idea to make it work ?
Upvotes: 0
Views: 263
Reputation: 2818
I'm pretty sure there's no way to fix this unfixed issue or by forking the latest hibernate 5.x and patch it.
Found this issue in Hibernate which explains a lot about the issue you are into (the important part is the 2nd newest comment by Hack Kampbjørn).
Trying to override jaxb-runtime / jaxb-api doesn't solve the problem neither.
EDIT
Updating to Hibernate 6 fails too.
Created issue in Hibernate : https://hibernate.atlassian.net/browse/HHH-17579
PR created : https://github.com/hibernate/hibernate-orm/pull/7646 (fix version would be 6.4.2.Final). Tested against https://github.com/laurentschoelens/hibernate-orm-xml-java11 OK
EDIT 2
PR merged in Hibernate. This will be available in v6.4.5 and v6.5.0
This should not make it's way to v5.6 but it's finally fixed
Upvotes: 0