I cannot get any variation of adding annotation processors to actually find the JAXB implement. I’ve trying using maven compile with annotation processors like above.
<profile>
<id>path</id>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<executions>
<execution>
<id>hibernate-jpamodelgen</id>
<configuration>
<annotationProcessors>
org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
</annotationProcessors>
<annotationProcessorPaths>
<path>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.4.4.Final</version>
</path>
</annotationProcessorPaths>
<verbose>false</verbose>
<compilerArgs>
<arg>-Adebug=true</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
And a maven processor plugin (this is how we are doing it with Java 8)
<profile>
<id>processor</id>
<build>
<plugins>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>3.3.3</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<processors>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</processors>
<fork>true</fork>
<releaseVersion>11</releaseVersion>
<options>
<debug>true</debug>
</options>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.4.4.Worldticket</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
Or adding the processor to dependencies as optional I need to enable debug output before even getting the warning about persistence.xml and orm.xml not being found. The processor continues anyway but without generating anything setup in the XML files
[INFO] — maven-processor-plugin:3.3.3:process (process) @ ticket-db-jpa —
Note: Hibernate JPA 2 Static-Metamodel Generator 5.4.4.Final
warning: Unable to parse persistence.xml: Unable to perform unmarshalling at line number 0 and column 0. Message: null
warning: Unable to parse /META-INF/orm.xml: Unable to perform unmarshalling at line number 0 and column 0. Message: null
When I debug this it always up in {{XmlParserHelper}}calling {{JAXBContext.newInstance}}without a classloader and all versions of JAXB API then use the context classloader which is the bootstrap classloader which in Java11 does not include the JAXB api or runtime. Just changing this line to use the same classloader that loaded the model processor make it work.
===================================================================
--- tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/XmlParserHelper.java (date 1564437374000)
+++ tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/XmlParserHelper.java (date 1567066288079)
@@ -119,7 +118,7 @@
ContextProvidingValidationEventHandler handler = new ContextProvidingValidationEventHandler();
try {
staxEventReader = new JpaNamespaceTransformingEventReader( staxEventReader );
- JAXBContext jaxbContext = JAXBContext.newInstance( ObjectFactory.class );
+ JAXBContext jaxbContext = JAXBContext.newInstance( ObjectFactory.class.getPackage().getName(), getClass().getClassLoader() );
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
unmarshaller.setSchema( schema );
unmarshaller.setEventHandler( handler );
|