-->
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.  [ 11 posts ] 
Author Message
 Post subject: Hibernate 2.1.8 and cglib 2.1_2 does not cooperate.
PostPosted: Sun Jul 10, 2005 8:18 am 
Newbie

Joined: Sun Jul 10, 2005 8:00 am
Posts: 4
Hibernate version: 2.1.8

I don't know if it is a bug, or not. But it's a really big problem for me.
SessionFactory doe's not initialize:

null
java.lang.NoClassDefFoundError
at net.sf.hibernate.impl.SessionFactoryImpl.<clinit>(SessionFactoryImpl.java:237)

The code in source is:
private static final QueryCacheKeyFactory QUERY_KEY_FACTORY;
private static final FilterCacheKeyFactory FILTER_KEY_FACTORY;
static {
->>> QUERY_KEY_FACTORY = (QueryCacheKeyFactory) KeyFactory.create(QueryCacheKeyFactory.class);
FILTER_KEY_FACTORY = (FilterCacheKeyFactory) KeyFactory.create(FilterCacheKeyFactory.class);
}

I suppose that it is something with class loader in new cglib joined with
the fact, that QueryCacheKeyFactory class is only package visible.
But it's not clearaly visible for me after short look at the cglib source code
- to tell the truth, I don't see the reason.

What do do now ?
With cglib-2.0-rc2 everything is OK (but there are other problems when
I try to deploy my application via Java Web Start).


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 10, 2005 10:10 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Can you post full stack trace ? It must be "ExceptionInInitializerError" and cause in this satck trace. "java.lang.NoClassDefFoundError" is thrown on the next attempt to use uninitialized class and it says nothing usefull.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 10, 2005 1:21 pm 
Newbie

Joined: Sun Jul 10, 2005 8:00 am
Posts: 4
baliukas wrote:
Can you post full stack trace ? It must be "ExceptionInInitializerError" and cause in this satck trace. "java.lang.NoClassDefFoundError" is thrown on the next attempt to use uninitialized class and it says nothing usefull.


Here it is - just after configuring ehcache:

* WARN Configurator:125 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/D:/JavaProjects/workspace/SkokCom30Dev/lib/ehcache-0.9.jar!/ehcache-failsafe.xml [19:17:46,281]
java.lang.NoClassDefFoundError
at net.sf.hibernate.impl.SessionFactoryImpl.<clinit>(SessionFactoryImpl.java:237)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:805)
at com.hands.skokcom3.dane.dao._RootDAO.initialize(_RootDAO.java:615)
at com.hands.skokcom3.logbiz.techniczne.ManagerPolecen.inicjujDostepDoBazy(ManagerPolecen.java:420)
at com.hands.skokcom3.logbiz.techniczne.manager_polecen.ObiektDostepuDoSesjiInterakcji.podajSesje(ObiektDostepuDoSesjiInterakcji.java:49)
at com.hands.skokcom3.logbiz.techniczne.ManagerPolecen.wykonajFunkcjeBiznesowa(ManagerPolecen.java:309)
at com.hands.skokcom3.logbiz.techniczne.ManagerPolecen.sWykonajFunkcjeBiznesowa(ManagerPolecen.java:118)
at com.hands.skokcom3.logbiz.techniczne.ManagerPolecen$1InterakcjaInicjujaca.glownePrzetwarzanie(ManagerPolecen.java:557)
at com.hands.skokcom3.interakcje.techniczne.ManagerInterakcji.uruchomInter(ManagerInterakcji.java:112)
at com.hands.skokcom3.interakcje.techniczne.ManagerInterakcji$1.run(ManagerInterakcji.java:172)
at java.lang.Thread.run(Unknown Source)

As you can see - the stack trace is not very deep and there's not too much info ... The message of NoClassDefFoundError is null. The _RootDAO.java:615 looks like this:

setSessionFactory(null, cfg.buildSessionFactory());


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 10, 2005 1:44 pm 
Newbie

Joined: Sun Jul 10, 2005 8:00 am
Posts: 4
baliukas wrote:
this satck trace. "java.lang.NoClassDefFoundError" is thrown on the next attempt to use uninitialized class


I'm sure there are no exceptions before.
I use java 5.0, and imb db2.

I simplified a litle method _RootDAO.initialize. It looks like:

public static synchronized void initialize() throws HibernateException {
if (sessionFactoryMap.size() > 0)
return;
else {
Configuration cfg = new Configuration();
cfg.configure("/hibernate.cfg.xml");
if (cfg.getProperty("hibernate.connection.username") == null) {
cfg.setProperty("hibernate.connection.username", "db2admin");
cfg.setProperty("hibernate.connection.password", "XXXXXXXX");
}
cfg.configure("/hibernate_mappings.xml");
try {
setSessionFactory(null, cfg.buildSessionFactory()); //<-- EXCEPTION !!!
} catch (Throwable t) {
t.printStackTrace(System.err);
System.err.flush();
}
}
}

.. and nothing changes ... Exception still the same.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 10, 2005 1:57 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
"java.lang.NoClassDefFoundError " is thrown in two cases by JVM:
1. No definition for a class could be found by the class loader
2. Class is in invalid state ( exception was thrown in initializer ) and class loader is trieng to load it again.
So if classpath is correct then try to find "ExceptionInInitializerError" in logs.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 10, 2005 2:02 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
BTW, are you sure hibernate 2.1.8 is compiled with cglib2 ?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 10, 2005 2:15 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
You can remove key factory from hibernate code and implement it manualy, it is trivial code anyway.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 11, 2005 6:05 pm 
Newbie

Joined: Sun Jul 10, 2005 8:00 am
Posts: 4
baliukas wrote:
BTW, are you sure hibernate 2.1.8 is compiled with cglib2 ?


:)
I've used library oryginally delivered with hibernate 2.1.8: cglib-full-2.0.2.jar and ... it goes !
And finally it goes via Java Web Start too (that was my main problem).
So all problems are solved ... :)))

I don't know why it does not work with cglib-2.1_2.jar - i can only suppose, that the library was not complete (it is smaller than cglib-full I finally used), but no enough debug info was available for JVM to form a precise error message.
[/img]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 5:21 am 
Newbie

Joined: Thu Jul 21, 2005 5:08 am
Posts: 1
I've solved a similar problem with hibernate+cglib. The problem is that not all cglib*.jar's comes with the org.objectweb.asm.Type class which causes the NoClassDefFoundError in Configuration.buildSessionFactory().
asm.jar, which comes with Hibernate, contains this class...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 5:52 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Ok, I will remove cglib jar without ASM for the next release, I see it confuses.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 16, 2006 10:10 am 
Newbie

Joined: Tue Jan 10, 2006 1:30 pm
Posts: 14
LoserBoy wrote:
I've solved a similar problem with hibernate+cglib. The problem is that not all cglib*.jar's comes with the org.objectweb.asm.Type class which causes the NoClassDefFoundError in Configuration.buildSessionFactory().
asm.jar, which comes with Hibernate, contains this class...


I am running Hibernate 3.0, and I have both cglib-2.0.jar and asm.jar in my classpath, yet I still get the NoClassDefError when hibernate is trying to start up (just as mentioned above). Has anyone had any luck with this problem?

_________________
Brian


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 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.