I need to get CGLIB working for both Hibernate 3.3.1 and Spring 2.5.6. AFAIK with Hibernate I am supposed to use hibernate-cglib-repack-2.1_3, while Spring requires cglib-nodep-2.1_3.
If I only include cglib-nodep then Hibernate barfs with:
Quote:
java.lang.NoClassDefFoundError: org/hibernate/repackage/cglib/proxy/CallbackFilter
at org.hibernate.bytecode.cglib.BytecodeProviderImpl.getProxyFactoryFactory(BytecodeProviderImpl.java:54)
If I only include hibernate-cglib-repack then Spring barfs with:
Quote:
java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
at org.springframework.beans.factory.support.CglibSubclassingInstantiationStrategy.instantiateWithMethodInjection(CglibSubclassingInstantiationStrategy.java:70)
..when trying to create a runtime proxy, because said class has 'import net.sf.cglib.proxy.CallbackFilter;
If I include both JARs then Hibernate's CGLib enhancement on domain objects fails with:
Quote:
org.hibernate.HibernateException: CGLIB Enhancement failed: com.doppelganger.domain.UserSettings
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxy(CGLIBLazyInitializer.java:119)
at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.getProxy(CGLIBProxyFactory.java:72)
because
net.sf.cglib.proxy.Enhancer from cglib-nodep has package name stored as a String:
Quote:
private static final Type CALLBACK = TypeUtils.parseType("net.sf.cglib.proxy.Callback");
and I guess when both JARs are included cglib-nodep appears first in the classpath.
So how can I get both Hibernate 3.3.1 and Spring 2.5.6 using CGLIB simultaneously? Also (out of curiosity) what was the point of repackaging CGLIB for Hibernate?
Seems like one solution is to ensure that all Strings like "net.sf.cglib" in hibernate-cglib-repackage are changed to "org.hibernate.repackage.cglib" - but I am unsure how to do that since this package is generated by altering cglib-nodep classes.
If anyone knows of a way out here (not including switching to the poorly-scaling javassist) please post - this issue is a complete blocker for us.
thanks!
-nikita