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:

java.lang.NoClassDefFoundError: org/hibernate/repackage/cglib/proxy/CallbackFilter
at org.hibernate.bytecode.cglib.BytecodeProviderImpl. getProxyFactoryFactory(BytecodeProviderImpl.java:5 4)

If I only include hibernate-cglib-repack then Spring barfs with:
java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
at org.springframework.beans.factory.support.CglibSub classingInstantiationStrategy.instantiateWithMetho dInjection(CglibSubclassingInstantiationStrategy.j ava:70)
..when trying to create a runtime proxy.


If I include both JARs then Hibernate's CGLib enhancement on domain objects fails with:

org.hibernate.HibernateException: CGLIB Enhancement failed: com.doppelganger.domain.UserSettings
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitialize r.getProxy(CGLIBLazyInitializer.java:119)
at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.g etProxy(CGLIBProxyFactory.java:72)
because net.sf.cglib.proxy.Enhancer from cglib-nodep has package name stored as a String:

private static final Type CALLBACK = TypeUtils.parseType("net.sf.cglib.proxy.Callback") ;
and I guess String value of CALLBACK variable isn't being changed from "net.sf.cglib..." to "org.hibernate.repackage.cglib..." when cglib-nodep -> hibernate-cglib-repack transform takes place (via Maven's Shade plugin)


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