-->
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.  [ 15 posts ] 
Author Message
 Post subject: Hibernate2 and Hibernate3 coexistence
PostPosted: Wed Aug 10, 2005 2:03 am 
Newbie

Joined: Mon Aug 08, 2005 10:50 am
Posts: 7
According to the manual Hibernate3 can co-exist with Hibernate2 in the same project. That is because the package naming convention has changed (from 'net.sf.' to 'org.hibernate.').
However, when introducing Hibernate3 in our (Portal-)project we run into problems.
In the Portal environment we have a classpath, just like in any other application. There seems to be a conflict between the helper jar's of the two versions of Hibernate:
If the helper jar named 'cglib-asm.jar' (of Hibernate2) preceeds the 'cglib-2.1.jar' (of Hibernate3), then Hibernate2 portlets work (but not Hibernate3 portlets). And vice versa, of course, if the order of the jars is reversed.
One may argue that this is a problem specific to WebSphere Portal. In order to verify that I ran a set of JUnit tests (as a Java application, not in the Portal), and I can reproduce the problem there. Obviously we are dealing with a more general problem.

Now, Hibernate2 and Hibernate3 are supposed to be able to co-exist. How can that be oachieved? I can't seem to find a solution!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 10, 2005 3:08 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
use the cglib/asm libraries from h3

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: To Max
PostPosted: Wed Aug 10, 2005 5:01 am 
Newbie

Joined: Mon Aug 08, 2005 10:50 am
Posts: 7
The whole issue is that Hibernate2 seems to break when I use the H3 libraries (and vice versa).
I'm looking for a way of circumventing that breakdown.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 10, 2005 7:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you wrote you had asm/cglib.jars from both h2 and h3 in the classpath - dont do that.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 10, 2005 8:14 am 
Newbie

Joined: Mon Aug 08, 2005 10:50 am
Posts: 7
But that is the whole point: According to the manual H2 and H3 can co-exist in the same application (==same classpath). If I remove one set then either H2 or H3 breaks (depending on which jars I remove).
For example, if I remove 'cglib-asm.jar' (which is required by H2), I get the following exception (assuming that hibernate2.jar is still in the classpath):
Code:
Nested Exception is java.lang.NoClassDefFoundError: net/sf/cglib/KeyFactory
   at net.sf.hibernate.impl.SessionFactoryImpl.<clinit>(SessionFactoryImpl.java:297)
   at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:627)


If I re-insert the 'cglib-asm.jar' file, I get a different error (depending on the order relative the H3 counterparts).
If I remove the H3 equivivalents I get yet another error.

Let's not resort to word-wrestling. I conclude from Your posts that the "Hibernate 3 Reference Manual" is incorrect insofar that Hibernate2 and Hibernate3 can, in fact, not co-exist in the same application, or if they can then at least You are not aware of how the system should be configured.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 10, 2005 8:50 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Yeah, bad us.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 10, 2005 10:54 am 
Beginner
Beginner

Joined: Thu Jul 07, 2005 7:12 pm
Posts: 25
vainov wrote:
But that is the whole point: According to the manual H2 and H3 can co-exist in the same application (==same classpath). If I remove one set then either H2 or H3 breaks (depending on which jars I remove).
For example, if I remove 'cglib-asm.jar' (which is required by H2), I get the following exception (assuming that hibernate2.jar is still in the classpath):
Code:
Nested Exception is java.lang.NoClassDefFoundError: net/sf/cglib/KeyFactory
   at net.sf.hibernate.impl.SessionFactoryImpl.<clinit>(SessionFactoryImpl.java:297)
   at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:627)



That's very strange, because in my CGLib jar for Hibernate 2 AND 3, the KeyFactory class exists in the net.sf.cglib.core package.

So what's going on in your case? Are you referring to that class manually in your code or something?


Top
 Profile  
 
 Post subject: H2 and H3 co-exist on Websphere
PostPosted: Wed Aug 10, 2005 10:59 am 
Beginner
Beginner

Joined: Thu Jul 21, 2005 10:28 am
Posts: 21
We use Websphere 5.1 Portal Server and we use Portlets, so we have some of the same issues you had. It took us a few days of working with this in order to figure out a configuration that works.

So, they are right, H2 and H2 CAN exist.

Should the Hibernate team be a little bit more knowledgeable when it comes to configuring their product on different servers, Yes! But that's not the issue.

I can tell you the first problem we had was with xml-apis.jar. The _README.txt documentation for H3.0.5 says that xml-apis.jar is required. But if you use the one that comes with H3, it breaks WPS 5.1 because of the way we load in classes. So, if you look ap WPS 5.1, you'll find another xml-apis.jar is already there, so you don't need the one from H3.

Also ... we use only the standard required jars:
hibernate3.jar, asm.jar, asm-attrs.jar

we also replaced our old cglib-full-2.0.2.jar with cglib 2.1 and replace ehcache-0.9.jar with ehcache-1.1 jar. For our project we removed all traces of these old jars (ehcache-0.9 and cglib-2.0.2).

If you're using IRAD6 (or eclipse), check the JAR dependencies and remove the old jars and make sure you only mark the new jars as required. That way the new jars will be in the manifest file.

Hope this helps you a little ....

Tom


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 10, 2005 10:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Actually, it looks like KeyFactory moved to the net.sf.cglib.core package. Should be straightforward to patch HB2 to work with latest cglib release.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 10, 2005 11:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Ah, scratch all this.

I just replaced cglib 2.0.2 with cglib 2.1.2 + asm jars and HB2 AllTests ran *perfectly*.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 10, 2005 12:09 pm 
Regular
Regular

Joined: Thu Dec 02, 2004 7:11 am
Posts: 85
gavin wrote:
Actually, it looks like KeyFactory moved to the net.sf.cglib.core package. Should be straightforward to patch HB2 to work with latest cglib release.


According to CVS this is already done in version 2105.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 10, 2005 12:38 pm 
Regular
Regular

Joined: Thu Dec 02, 2004 7:11 am
Posts: 85
To vainov: You just have to upgrade H2 to lastest version and use new cglib library.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 10, 2005 1:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
sergeya wrote:
To vainov: You just have to upgrade H2 to lastest version and use new cglib library.


Yes, exactly. I'm rather annoyed with the tone of Vainov's posts, given that the problem is clearly at his end (running an obsolete version of HB2).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 3:11 am 
Newbie

Joined: Mon Aug 08, 2005 10:50 am
Posts: 7
My apologies. It was not my intention to offend anyone.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 11:18 am 
Newbie

Joined: Mon Aug 08, 2005 10:50 am
Posts: 7
Summing up:
I now have Hibernate 2 and Hibernate 3 working concurrently in the same Portal server. Thank you for all the help, dear colleagues!
I thought I would post my findings here, in case someone else searches the forums for a similar scenario.

Starting from the bottom, the helper jars and versions that I use are as follows:
- asm-1.5.3.jar (NB! asm2.0.jar did NOT work!!)
- antlr2.7.5H3.jar (took it from Hibernate3; is has been patched by Hibernate!)
- cglib-2.1_2.jar
- commons-collections-3.1.jar
- commons-logging-1.0.4.jar
- dom4j-1.6.1.jar
- ehcache-1.1.jar
Those versions are the most recent ones (with the notable exception of 'asm'). I guess that other versions might work as well.
We are working in an IBM Websphere Portal environment. Replacing 'xerces' with the most recent version gave the PortalServer the hickups, so I stuck with the old one found in the 'ibm-was-lib'. Works fine.

We were using an old 'hibernate2.jar' file that originated from version 2.0.3. I replaced it with the 'hibernate2.jar' from version 2.1. It is still unclear to me what H2 versions can or can't co-exist with H3. Obviously, if your project uses 2.0.3 or older the viable path seems to be to first upgrade H2.

Now, since 'running an obsolete version of HB2' clearly puts the problem at my end, I will consider a switch back to EJB3.0 when it becomes available.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.