Announcement Announcement Module
No announcement yet.
JAR conflict: CGLib Spring + Hibernate 3.3.1. Help! Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JAR conflict: CGLib Spring + Hibernate 3.3.1. Help!

    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( 4)

    If I only include hibernate-cglib-repack then Spring barfs with:
    java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
    at 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(
    at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.g etProxy(
    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.


  • #2
    Not so much help, but we can vote HHH-3504, Probably you've already voted.
    Last edited by pedro; Feb 5th, 2009, 04:25 PM.


    • #3
      Actually I checked out cglib-nodep-2.1_3, refactored it, and built a working hibernate-cglib-nodep. Works fine. Will post the JAR + sources to Hibernate JIRA you reference above today.



      • #4
        Has anybody worked around this issue? I, too, am using Spring 2.5.6 and trying to upgrade to Hibernate 3.3.1 and I can't get past my cglib errors.