-->
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.  [ 5 posts ] 
Author Message
 Post subject: NoClassDefFoundError from cglib with Eclipse platform.
PostPosted: Tue Jul 25, 2006 2:34 pm 
Newbie

Joined: Tue Jul 25, 2006 1:56 pm
Posts: 2
Location: Foster City, CA
I am contributing the persistence layer to an Eclipse RCP application. I created a hibernate plugin by putting the complete distribution in the plugin directory. This plugin also contains a HibernateUtil class and some types. The jdbc driver for each database is in its own plugin along with database specific types and configuration code. The application code is in several other plugins. The mapping files are in yet another. Finally I have a JUnit test plugin that runs the test in the eclipse platform. This all works, but during Configuration.buildSessionFactory() I get the following exception whenever a proxy is constructed by cglib. I assume that this is going to ruin my startup performance. Any ideas about how to stop it?

Hibernate version:3.1.3
Eclipse version: 3.1
Mapping documents:Any with lazy="true"

Code between sessionFactory.openSession() and session.close(): Happens before openSession(

Full stack trace of any exception that occurs:
11:07:15,750 ERROR BasicLazyInitializer:130 - CGLIB Enhancement failed: com.apldbio.seqshared.model.analysis.annotation.AmpliconFeature
net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317)
at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:126)
at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:41)
at org.hibernate.tuple.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:161)
at org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:131)
at org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:257)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:216)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at com.apldbio.ga.hibernate.HibernateUtil.start(HibernateUtil.java:60)
at com.apldbio.ajax.hibernate.AjaxHibernateOracleTest.startDatabase(AjaxHibernateOracleTest.java:39)
at com.apldbio.ajax.hibernate.TestAjaxWithHibernate.testStartDatabase(TestAjaxWithHibernate.java:52)
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:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:57)
at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:24)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
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:585)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
at org.eclipse.core.launcher.Main.run(Main.java:973)
at org.eclipse.core.launcher.Main.main(Main.java:948)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
... 44 more
Caused by: java.lang.NoClassDefFoundError: org/hibernate/proxy/HibernateProxy
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
... 49 more

Name and version of the database you are using:Oracle 8.1.7 with the 10g thin driver, Derby 10.1 embedded, HSQLDB 1.8 embedded.

The generated SQL (show_sql=true):none

Debug level Hibernate log excerpt:none


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 26, 2006 2:12 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Application pluggin must depend on hibernate pluggin, proxies are generated in application pluggin class loader but proxy depends on Hibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 26, 2006 3:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
read up about eclipse buddy classloading.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: NoClassDefFoundError from cglib with Eclipse platform.
PostPosted: Wed Jul 26, 2006 1:46 pm 
Newbie

Joined: Tue Jul 25, 2006 1:56 pm
Posts: 2
Location: Foster City, CA
Buddy loading does not help. Having the application plugins depend on hibernate is not acceptable because we want versions that don't use hibernate. After I posted, I found another example of the same problem from 2005, but no fixes. I found it hard to believe that no one has found a way arround this before, but I have. The class org.hibernate.proxy.CGLIBLazyInitializer creates an instance of net.sf.cglib.proxy.Enhancer. Enhancer has a setClassLoader method. So, I extracted CGLIBLazyIntializer and added the following line of code after the Enhancer is created

Enhancer en = new Enhancer();
en.setClassLoader(CGLIBLazyInitializer.class.getClassLoader());

This solves the problem.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 26, 2006 1:56 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you will run into more issues that will require buddy classloading.

As soon as Hibernate needs to load classes dynamically it needs to see *your* classes not just it self.

And do note this is a eclipse-quirk and buddy classloading does not enforce any dependency afaik.

_________________
Max
Don't forget to rate


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