-->
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.  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: [HB-1064] FastClass NoClassDefFoundError w/2.1.4
PostPosted: Mon Aug 02, 2004 2:28 pm 
Newbie

Joined: Sun Dec 28, 2003 2:07 pm
Posts: 15
Location: Quebec, Canada
Hi,

I was using Hibernate 2.0.2, and things were working fine. Now, I'm trying to upgrade to 2.1.4, and I get the following stack trace (abriged - see issue[1] for full details):
Code:
2004-07-25 00:39:36,234 [INFO ] f.hibernate.util.ReflectHelper - reflection optimizer disabled for: javax.mail.internet.InternetAddress, CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
2004-07-25 00:39:36,250 [ERROR] work.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in resource [/WEB-INF/applicationContext.xml] of ServletContext: Initialization of bean failed; nested exception is net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:208)
at net.sf.cglib.reflect.FastClass$Generator.create(FastClass.java:92)
at net.sf.cglib.reflect.FastClass.create(FastClass.java:74)
...
Caused by: java.lang.NoClassDefFoundError: net/sf/cglib/reflect/FastClass
at java.lang.ClassLoader.defineClass0(Native Method)


I'm using Hibernate 2.1.4 on Tomcat 4.1.30, J2SE 1.4.2_03 on Windows 2K and XP.

Christian Bauer requested a reproduction recipe, which I've done. Again, see the issue[1] for full details.

My analysis of the problem is that I am trying to map a
Code:
javax.mail.internet.InternetAddress
. I am mapping using the following component:
Code:
    <component name="email" class="javax.mail.internet.InternetAddress">
        <property name="personal" column="personal" type="string" length="80"/>
        <property name="address" column="address" type="string" length="240"/>
    </component>


Is my mapping incorrectly done ? As I said earlier, Hibernate 2.0.2 was working fine with a similar mapping.

Have a nice day !
Fran


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 02, 2004 2:43 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You are the only person on the planet that has this issue. You still think this is a "Hibernate bug"? Thousands of people follow the "Quickstart" directions and have no problems with their classpath.

I just downloaded your zip file and it doesn't have any Hibernate connection configuration. If you can afford my hourly rate, I'll debug your application. If you can't, follow the Quickstart word by word.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 02, 2004 3:01 pm 
Newbie

Joined: Sun Dec 28, 2003 2:07 pm
Posts: 15
Location: Quebec, Canada
Look, Christian, I'm not trying to be obtuse or anything. I'm staying very courteous, and all.

My last question is not "Hibernate has a bug", but "Am I mapping InternetAddress correctly ?"

I'm certainly not asking you to debug my application.

For the repro recipe, fair enough. Let me change it so that it uses HSQLDB, and works out-of-the box.

Bye,
Fran


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 02, 2004 3:05 pm 
Newbie

Joined: Sun Dec 28, 2003 2:07 pm
Posts: 15
Location: Quebec, Canada
BTW, the repro recipe doesn't need connection information. The database doesn't need to be contacted for the problem to manifest itself.

Did you run it ? Or did you only take a look ?

Bye,
Fran


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 02, 2004 3:07 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Then don't wrap your trivial mapping question inside a pseudo bug report. The correct procedure is NOT to put some zip file for download where we have to spent an hour debugging your code, but to simply follow the instructions we give. If I say "follow the Quickstart word by word" and it works, fine. If it doesn't, you can tell us why you didn't follow it word by word and we will see if it makes sense.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 03, 2004 5:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the error says it cannot find FastClass - do you have the correct cglib in the classpath ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 9:19 am 
Newbie

Joined: Sun Dec 28, 2003 2:07 pm
Posts: 15
Location: Quebec, Canada
Yup.

If you downlod the BZIP2, you'll find that I copy the one distributed with Hibernate 2.1.4.

This is a subtle classloader issue. I'm in the process of making the quickstart crash with the same error.

Bye,
Fran


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 10:26 am 
Newbie

Joined: Sun Dec 28, 2003 2:07 pm
Posts: 15
Location: Quebec, Canada
christian wrote:
You are the only person on the planet that has this issue. You still think this is a "Hibernate bug"? Thousands of people follow the "Quickstart" directions and have no problems with their classpath.


Please see the last comment on HB-1064 at http://opensource.atlassian.com/project ... se/HB-1064

I have followed the quickstart to the letter. I have included a detailed log of each modification I made to any file or code copy.

I don't think I've missed anything.

But, I get the NoClassDefFoundError anyway.

Bye,
Fran


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 10:50 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
What is "InternetAddress" and why do you think you can map it as a <component>?

Please discuss this here, its clearly a user problem. The worst I can see is a not-perfect exception message thrown by Hibernate, when it should actually tell you what mapping is wrong.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 10:56 am 
Newbie

Joined: Sun Dec 28, 2003 2:07 pm
Posts: 15
Location: Quebec, Canada
InternetAddress is part of the javax.mail package.

It is a subclass of javax.mail.Address, which encapsulates the concept of a user's E-Mail address.

InternetAddress is a concrete subclass representing an RFC-822 address.

I believed I could map an InternetAddress using a component, because the implementation of InternetAddress exposes bean properties for the personal and address part, plus it has a public, no-arg constructor.

References:
JavaMail API:
http://java.sun.com/products/javamail/j ... index.html

javax.mail.Address:
http://java.sun.com/products/javamail/j ... dress.html

javax.mail.internet.InternetAddress:
http://java.sun.com/products/javamail/j ... dress.html

Thanks,
Fran


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 11:01 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Copy mail.jar to WEB-INF/lib. Don't touch and never even look at common/lib in Tomcat. It's not for you, its for the container.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 11:08 am 
Newbie

Joined: Sun Dec 28, 2003 2:07 pm
Posts: 15
Location: Quebec, Canada
Ok. I continued the QuickStart, and copied the mail.jar and activation.jar (mail depends on activation) to WEB-INF/lib.

Restarted Tomcat, and still the same stack trace:

Code:
2004-08-05 10:59:42 net.sf.hibernate.cfg.Configuration addInputStream
GRAVE: Could not configure datastore from input stream
net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
...
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:411)
        at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:195)
        ... 35 more
Caused by: java.lang.NoClassDefFoundError: net/sf/cglib/reflect/FastClass
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
        ... 41 more


Here's a listing of my webapps/quickstart folder:
Code:
WEB-INF
WEB-INF\classes
WEB-INF\classes\Cat.hbm.xml
WEB-INF\classes\hibernate.cfg.xml
WEB-INF\classes\net
WEB-INF\classes\net\sf
WEB-INF\classes\net\sf\hibernate
WEB-INF\classes\net\sf\hibernate\examples
WEB-INF\classes\net\sf\hibernate\examples\quickstart
WEB-INF\classes\net\sf\hibernate\examples\quickstart\Cat.class
WEB-INF\classes\net\sf\hibernate\examples\quickstart\Cat.java
WEB-INF\classes\net\sf\hibernate\examples\quickstart\HibernateServlet.class
WEB-INF\classes\net\sf\hibernate\examples\quickstart\HibernateServlet.java
WEB-INF\classes\net\sf\hibernate\examples\quickstart\HibernateUtil.class
WEB-INF\classes\net\sf\hibernate\examples\quickstart\HibernateUtil.java
WEB-INF\lib
WEB-INF\lib\activation.jar
WEB-INF\lib\cglib-full-2.0.1.jar
WEB-INF\lib\commons-collections-2.1.jar
WEB-INF\lib\commons-logging-1.0.3.jar
WEB-INF\lib\dom4j-1.4.jar
WEB-INF\lib\ehcache-0.7.jar
WEB-INF\lib\hibernate2.jar
WEB-INF\lib\mail.jar
WEB-INF\web.xml


All libraries were copied from Hibernate's 2.1.4 distribution, except for mail and activation.

Thank you for taking the time to walk me through this problem.

I don't know if you've noticed me saying so before, but InternetAddress was successfully mapped in Hibernate 2.0.2. It's only when I attempted to upgrade to 2.1.4 that I found out about this error.

Bye !
Fran


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 11:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Do you probably have some old cglib jar somwhere in the tomcat classpath? like in common/lib or such?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 11:12 am 
Newbie

Joined: Sun Dec 28, 2003 2:07 pm
Posts: 15
Location: Quebec, Canada
Nope, the only one is the one I really want there:

Code:
$ dir jakarta-tomcat-4.1.30\*cg*.jar /s/b
E:\quickstart\jakarta-tomcat-4.1.30\webapps\quickstart\WEB-INF\lib\cglib-full-2.0.1.jar


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 12:15 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Remove mail.jar and activation.jar from Tomcats common/lib/ as a workaround.

This is how Hibernate tries to load the InternetAddress component class:

return create(type.getClassLoader(),type);

The "type" is "InternetAddress.class". Apparently, the classloader that is returned by this call is the Tomcat container classloader, not the context classloader. CGLib has then some problems creating a reflection proxy for this.

Juzoas, Gavin, your job.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ]  Go to page 1, 2  Next

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.