[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3826?page=c...
]
Denys Kurylenko commented on HHH-3826:
--------------------------------------
However I have another solution. Instead of adding hibernate/javassist packages to the
Import-Packages of the domain class bundle we can just configure JavaAssist ClassLoader
properly.
JavaAssist ClassLoader should be exactly the same as bundle ClassLoader that tries to
instantiate LocalSessionFactoryBean.
So assume we have two modules : domain and persistence-mgr. Originally JavaAssist tries to
instantiate Proxy class using domain module ClassLoader. But as [~vanwijngaarden]
mentioned we won't have access to the hibernate/javaassist classes in the domain
ClassLoader.
Utility class that sets proper classloader to the JavaAssis :
{code:title=JavaAssistHelper.java|borderStyle=solid}
import javassist.util.proxy.ProxyFactory;
import javassist.util.proxy.ProxyFactory.ClassLoaderProvider;
public class JavaAssistHelper
{
public static ClassLoaderProvider createJavaAssistClassLoader()
{
ProxyFactory.classLoaderProvider = new ProxyFactory.ClassLoaderProvider()
{
public ClassLoader get(ProxyFactory pf)
{
return Thread.currentThread().getContextClassLoader();
}
};
return ProxyFactory.classLoaderProvider;
}
}
{code}
Spring configuration :
{code:xml}
<bean id="sessionFactory" depends-on="javaAssistClassLoader"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="datasource"/>
<property name="configLocation"
value="hibernate_cfg/hibernate.cfg.xml"/>
</bean>
<bean id="javaAssistClassLoader"
class="com.*.*.JavaAssistHelper"
factory-method="createJavaAssistClassLoader"/>
{code}
We don't need to have any fix for this bug. It's not Hibernate bug, or bug at
all.
Hibernate 3.3.1.GA + Javassist issue 3.9.0.GA :
java.lang.RuntimeException: by java.lang.NoClassDefFoundError:
org/hibernate/proxy/HibernateProxy (OSGI Server)
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-3826
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3826
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.3.1
Reporter: Charles Moulliard
Hi,
I try to use Hibernate 3.3.1.GA in combination with Spring OSGI 1.2.0-rc1. Unfortunately,
there is a classloading issue on OSGI :
{code}
Caused by: java.lang.RuntimeException: by java.lang.NoClassDefFoundError:
org/hibernate/proxy/HibernateProxy
at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:174)
at
org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxyFactory(JavassistLazyInitializer.java:162)
... 58 more
Caused by: javassist.CannotCompileException: by java.lang.NoClassDefFoundError:
org/hibernate/proxy/HibernateProxy
at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:167)
at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:170)
... 59 more
Caused by: java.lang.NoClassDefFoundError: org/hibernate/proxy/HibernateProxy
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:159)
... 60 more
{code}
remark : the package org.hibernate.proxy is defined in the MANIFEST file (section -
Import-PAckage)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira