HHH-17579 fix classloader issues with JAXBContext since JDK11
This commit is contained in:
parent
557a4f16da
commit
6941ddd58c
|
@ -9,6 +9,7 @@ package org.hibernate.processor.util.xml;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import javax.tools.FileObject;
|
import javax.tools.FileObject;
|
||||||
|
@ -120,7 +121,14 @@ public class XmlParserHelper {
|
||||||
ContextProvidingValidationEventHandler handler = new ContextProvidingValidationEventHandler();
|
ContextProvidingValidationEventHandler handler = new ContextProvidingValidationEventHandler();
|
||||||
try {
|
try {
|
||||||
staxEventReader = new JpaNamespaceTransformingEventReader( staxEventReader );
|
staxEventReader = new JpaNamespaceTransformingEventReader( staxEventReader );
|
||||||
JAXBContext jaxbContext = JAXBContext.newInstance( ObjectFactory.class );
|
|
||||||
|
// Class.getClassLoader() may return null if the class was loaded by the bootstrap class loader,
|
||||||
|
// but since we don't expect the annotation processor to be loaded by that class loader,
|
||||||
|
// we expect the return to be non-null and hence cast
|
||||||
|
ClassLoader cl = NullnessUtil.castNonNull( ObjectFactory.class.getClassLoader() );
|
||||||
|
String packageName = NullnessUtil.castNonNull( ObjectFactory.class.getPackage() ).getName();
|
||||||
|
JAXBContext jaxbContext = JAXBContext.newInstance( packageName, cl );
|
||||||
|
|
||||||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
||||||
unmarshaller.setSchema( schema );
|
unmarshaller.setSchema( schema );
|
||||||
unmarshaller.setEventHandler( handler );
|
unmarshaller.setEventHandler( handler );
|
||||||
|
|
Loading…
Reference in New Issue