-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: JAR conflict: CGLib Spring + Hibernate 3.3.1. Help!
PostPosted: Wed Feb 04, 2009 2:11 pm 
Newbie

Joined: Wed Feb 04, 2009 1:44 pm
Posts: 7
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


Top
 Profile  
 
 Post subject: RE: JAR conflict: CGLib Spring + Hibernate 3.3.1.
PostPosted: Wed Feb 04, 2009 2:42 pm 
Newbie

Joined: Wed Feb 04, 2009 1:44 pm
Posts: 7
Indeed, String "net.sf.cglib" is not being replaced when hibernate-cglib-repack is being built:


c:\code\hibernate\hibernate-cglib-repack-2.1_3\target>javap -c -classpath . org\hibernate\repackage\cglib\proxy\Enhancer

Compiled from "Enhancer.java"
public class org.hibernate.repackage.cglib.proxy.Enhancer extends org.hibernate.repackage.cglib.core.AbstractClassGenera
tor{
.
.
.
.
118: putstatic #1284; //Field CALLBACK:Lorg/hibernate/repackage/cglib/asm/Type;
121: ldc_w #957; //String [Lnet/sf/cglib/proxy/Callback;

124: invokestatic #1407; //Method org/hibernate/repackage/cglib/asm/Type.getType:(Ljava/lang/String;)Lorg/hibernat
e/repackage/cglib/asm/Type;
127: putstatic #1163; //Field CALLBACK_ARRAY:Lorg/hibernate/repackage/cglib/asm/Type;


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2009 7:53 pm 
Regular
Regular

Joined: Thu Aug 28, 2003 2:42 pm
Posts: 77
Location: The Netherlands
He Nikita,

I noticed your post and that you just posted the repackage source in the bug.
But can you tell me how to use it and whay your solution is ?

Regards,
Ed


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2009 8:00 pm 
Newbie

Joined: Wed Feb 04, 2009 1:44 pm
Posts: 7
Please see this link for fix and explanation:
http://opensource.atlassian.com/project ... tion_32329


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2009 8:12 pm 
Regular
Regular

Joined: Thu Aug 28, 2003 2:42 pm
Posts: 77
Location: The Netherlands
Yep, just go the confirmation of the bug.
Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2009 6:28 am 
Newbie

Joined: Tue Feb 17, 2009 1:10 am
Posts: 2
Location: india
hi everyone

when i replaced the hibernate-cglib-repack-nodep-2.1_3.jar with cglib.jar of 3.2.5 release . it works fine
is it fine to use jars from different versions?

_________________
Thanks,
Sabitha


Top
 Profile  
 
 Post subject: Re: JAR conflict: CGLib Spring + Hibernate 3.3.1. Help!
PostPosted: Fri Sep 24, 2010 8:57 am 
Newbie

Joined: Mon Jul 13, 2009 9:00 am
Posts: 7
I'm sorry for reviving this old thread, but I'm having the same problems as the person who started this thread. Does someone have a solution which does not include modifying java code and rebuilding the jar-file? I really want to avoid that :).

Our application includes 2 main components, a webapp and a desktop client. When we need data, the client requests information from the webapp (which offers a few services to retrieve the necessary data). First, I included cglib, but when i transferred the necessary objects to the client, I got the error "NoClassDefFoundError" for InvocationHandler. To get around that, I added the hibernate-cglib-repack library, but then I received "CGLIB enhancement fail".

I'm getting a bit desperate tbh :).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.