HHH-13696 Use PU Info Classloader when booting in OsgiPersistenceProvider

This commit is contained in:
Kaja Mohideen 2019-09-06 20:07:56 +05:30 committed by Sanne Grinovero
parent 1dd787eaa1
commit 051a7d9b7c
1 changed files with 9 additions and 2 deletions

View File

@ -92,9 +92,16 @@ public class OsgiPersistenceProvider extends HibernatePersistenceProvider {
osgiClassLoader.addClassLoader( info.getClassLoader() ); osgiClassLoader.addClassLoader( info.getClassLoader() );
ClassLoader prevCL = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(info.getClassLoader());
return Bootstrap.getEntityManagerFactoryBuilder( info, settings, return Bootstrap.getEntityManagerFactoryBuilder( info, settings,
new OSGiClassLoaderServiceImpl( osgiClassLoader, osgiServiceUtil ) ).build(); new OSGiClassLoaderServiceImpl( osgiClassLoader, osgiServiceUtil ) ).build();
} }
finally {
Thread.currentThread().setContextClassLoader(prevCL);
}
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private Map generateSettings(Map properties) { private Map generateSettings(Map properties) {