|
I think it would be best to use the ClassLoader from the requestingBundle in the OsgiPersistenceProvider instead of creating a new ClassLoader that is mashing the ClassLoaders of all bundles using Hibernate in one OsgiClassLoader. By using the ClassLoader from the requestingBundle and not using the OsgiClassLoader there is no need track bundle events to cleanup.
I've tried this approach in PR 958 [1] on the 4.3 branch, there I'm using TCCL to make sure the ClassLoader from the requestingBundle is used, Steve mentioned on the Apache Karaf mailing list that Hibernate 5 doesn't rely on TCCL as much as 4.3 did so there may be a better way to make sure the correct ClassLoader is used by now.
[1]: https://github.com/hibernate/hibernate-orm/pull/958
|