|
Hi Steve,
Did a quick test, the only ClassLoader issue that I have is the one in the org.hibernate.proxy.pojo.javassist.JavassistProxyFactory#buildJavassistProxyFactory.
One can workaround this issue by importing the org.hibernate.proxy and javassist.util.proxy packages in the bundle bundle containing the entity class.
I've also did a quick test changing the org.hibernate.proxy.pojo.javassist.JavassistProxyFactory#buildJavassistProxyFactory method to use a ClassLoader that aggregates two ClassLoaders (the Hibernate ClassLoader and the ClassLoader of the entity class). This resolves the issue and I don't see any ClassLoader issues.
public static javassist.util.proxy.ProxyFactory buildJavassistProxyFactory(
final Class persistentClass,
final Class[] interfaces) {
javassist.util.proxy.ProxyFactory factory = new javassist.util.proxy.ProxyFactory() {
@Override
protected ClassLoader getClassLoader() {
final ClassLoader cl1 = persistentClass.getClassLoader();
final ClassLoader cl2 = HibernateProxy.class.getClassLoader();
return new ClassLoader() {
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
try {
return cl1.loadClass(name);
} catch (ClassNotFoundException cnfe) {
return cl2.loadClass(name);
}
}
};
}
};
factory.setSuperclass( interfaces.length == 1 ? persistentClass : null );
factory.setInterfaces( interfaces );
factory.setFilter( FINALIZE_FILTER );
return factory;
}
|