-->
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.  [ 28 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: NoClassDefFoundError when initialising Hibernate...
PostPosted: Fri Apr 15, 2005 12:02 pm 
Beginner
Beginner

Joined: Tue Feb 01, 2005 8:38 am
Posts: 38
Hibernate version:
3.0 Final.

Hi,

I am trying to initialise Hibernate from a stateless session bean deployed on Sun One app server 7 using the following code...

Code:
sessionFactory = new Configuration().configure().buildSessionFactory();


...somewhere in the initialisation I get this NoClassDefFoundError...

Code:
java.lang.NoClassDefFoundError
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1054)
        at com.o2.roamingCharges.dataLayer.DataManager.<init>(DataManager.java:111)
        at com.o2.roamingCharges.dataLayer.DataManager.getInstance(DataManager.java:58)
        at com.o2.roamingCharges.servicesLayer.SBApplicationMetaDataBean.<init>(SBApplicationMetaDataBean.java:64)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
        at java.lang.Class.newInstance0(Class.java:308)
        at java.lang.Class.newInstance(Class.java:261)
        at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:482)
        at com.sun.ejb.containers.StatelessSessionContainer.access$000(StatelessSessionContainer.java:68)
        at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:735)
        at com.sun.ejb.containers.util.pool.NonBlockingPool.getObject(NonBlockingPool.java:176)
        at com.sun.ejb.containers.StatelessSessionContainer.getContext(StatelessSessionContainer.java:458)
        at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:495)
        at com.myapp.SBApplicationMetaDataBean_EJBObjectImpl.getMessage(SBApplicationMetaDataBean_EJBObjectImpl.java:27)
        at com.myapp.servicesLayer._SBApplicationMetaDataBean_EJBObjectImpl_Tie._invoke(Unknown Source)
        at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatchToServant(GenericPOAServerSC.java:569)
        at com.sun.corba.ee.internal.POA.GenericPOAServerSC.internalDispatch(GenericPOAServerSC.java:211)
        at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatch(GenericPOAServerSC.java:113)
        at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:275)
        at com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProcessor.java:83)
        at com.iplanet.ias.corba.ee.internal.iiop.ServicableWrapper.service(ServicableWrapper.java:25)
        at com.iplanet.ias.util.threadpool.FastThreadPool$ThreadPoolThread.run(FastThreadPool.java:288)
        at java.lang.Thread.run(Thread.java:534)


...The problem appears to be happening at line 1054 in org.hibernate.cfg.Configuration - this is the line in question...
Code:
return new SessionFactoryImpl( this, mapping, settings, sessionEventListenerConfig.shallowCopy() );


...I have the following jars in the server lib directory (making them available on the classpath for any classes in my application). Hibernate seems to require these.
    asm.jar
    asm-attrs.jar
    asm-util.jar
    c3p0-0.9.0-pre4.jar
    cglib-2.1.jar
    cglib-docs-2.1.jar
    cglib-src-2.1.jar
    classes12.zip
    commons-collections-2.1.1.jar
    commons-dbcp-1.2.1.jar
    commons-lang-2.0.jar
    dom4j-1.5.2.jar
    ehcache-1.1.jar
    hibernate3.jar
    log4j-1.2.9.jar
    jdbc2_0-stdext.jar
    jta.jar
    proxool-0.8.3.jar


Is there another jar that I'm missing? It's very hard to tell what's going on given that the stacktrace doesn't say what class-def it can't find.

This problem only occurs when initialising on the app server - it runs fine when initialised from a stand-alone client which, incidentally, doesn't have half those jars on the classpath!

Any ideas anyone?

Cheers,

:)


Top
 Profile  
 
 Post subject: Sun One server with Hibernate still can't integrate!!
PostPosted: Mon Apr 18, 2005 6:39 am 
Beginner
Beginner

Joined: Wed Apr 13, 2005 12:49 pm
Posts: 34
Hey Scarlog,

I'm having the an extremely similar problem I think or something along those lines. Trying to deploy an app that incorporates Hibernate into Sun Appserver? I've tried both appserver7 & 8 at this stage and no joy.

The NoclassDefFoundException I'm getting is for the Configuration
class, org.hibernate.cfg.Configuration itself! At least you're getting that!

I've included most of the jars you've mentioned there into whatever lib folders I can find.

* cglib.jar
* commons-collections.jar
* commons-logging.jar
* commons-lang.jar
* jcs.jar
* odmg.jar
* hibernate.jar

%AppServerHome%\share\lib
%AppServerHome%\domains\domain1\lib

and also into the actual ear itself which sun one didn't like one bit.

Basically I couldn't find any docs available on the hibernate website detailing
the integration for Sun one so I tried to apply the docs detailing the

Jboss integration
http://www.hibernate.org/82.html

And the WSAD 5.0 integration.
http://www.hibernate.org/173.html

to Sun One but so far no good.

Lo there Hibernators.. Any docs available for Sun One integration at all at all?
Are there any other jars that maybe have to be included?
Any help would be greatly appreciated as I've put my neck on the line here in work suggesting we use hibernate and so far we haven't been able to get it integrated.

Thanks,
Mark.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 7:29 am 
Regular
Regular

Joined: Tue Nov 23, 2004 7:42 am
Posts: 82
Location: London, England
Do you have the antlr jar in your classpath?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 7:31 am 
Beginner
Beginner

Joined: Wed Apr 13, 2005 12:49 pm
Posts: 34
Hi Rilux,

Thanks for getting back to me.

I'm afraid I don't have the antlr jar in my classpath?
What is it used for?

Mark.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 7:32 am 
Regular
Regular

Joined: Tue Nov 23, 2004 7:42 am
Posts: 82
Location: London, England
I upgraded my app to hibernate3 over the weekend and it was an extra jar that Hibernate needed in order to work. It comes with Hibernate3 so you should find it in the lib dir.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 7:34 am 
Beginner
Beginner

Joined: Wed Apr 13, 2005 12:49 pm
Posts: 34
Sound as a bell Rilux!!
I'll give it a bash.

Thanks again for the reply.

Mark.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 7:35 am 
Beginner
Beginner

Joined: Tue Feb 01, 2005 8:38 am
Posts: 38
Yeah, I spotted I was missing that one this morning and added antlr-2.7.4.jar to the classpath. Still no joy... :(


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 7:38 am 
Regular
Regular

Joined: Tue Nov 23, 2004 7:42 am
Posts: 82
Location: London, England
Scorlóg wrote:
Yeah, I spotted I was missing that one this morning and added antlr-2.7.4.jar to the classpath. Still no joy... :(


I just upgraded Hibernate, cglib, and ehcache and added asm.jar and the antlr jar and everything was happy. Oh, I needed to change the DTD version in my mapping files too, but that was no biggie.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 7:43 am 
Beginner
Beginner

Joined: Tue Feb 01, 2005 8:38 am
Posts: 38
Hmmm... all the jars I'm using are the ones that came with the Hibernate 3 final distribution. I don't understand how it's giving a NoClassDefFoundError but it's not saying what class-def it can't find. Some input/suggestions from the hibernate team would be a big help here guys...

What DTD are you using in your mappings? I'm using http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd

Cheers :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 7:48 am 
Regular
Regular

Joined: Tue Nov 23, 2004 7:42 am
Posts: 82
Location: London, England
Scorlóg wrote:
Hmmm... all the jars I'm using are the ones that came with the Hibernate 3 final distribution. I don't understand how it's giving a NoClassDefFoundError but it's not saying what class-def it can't find. Some input/suggestions from the hibernate team would be a big help here guys...

What DTD are you using in your mappings? I'm using http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd

Cheers :)


Don't forget to change the DTD in hibernate.cfg.xml (if you use it) to http://hibernate.sourceforge.net/hibern ... on-3.0.dtd

Do you have any logging/debugging statements in your code? In the place where the exception is being caught can you print the stacktrace? I do my logging with log4j. Do you have the stacktrace to hand anywhere? It would be helpful to see it.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 7:57 am 
Regular
Regular

Joined: Tue Nov 23, 2004 7:42 am
Posts: 82
Location: London, England
Another thought.

Have you made sure all your net.sf.hibernate refs are now org.hibernate?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 7:58 am 
Beginner
Beginner

Joined: Wed Apr 13, 2005 12:49 pm
Posts: 34
Hey lads,

Some success! I put all the jars that scorlog mentioned into the

%AppserverHome%domains/domain1/lib directory and re-deployed my
app and now I'm getting the same NoClassDefFoundException as scorlog.


java.lang.NoClassDefFoundError
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1054)
at ie.takeit.hibernation.TestBean.Hibinit(TestBean.java:102)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

Rilux have you got hibernate working within Sun Appserver? Just knowing that would be something I could inform my team with ;-)

Thanks,
Mark.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 9:00 am 
Regular
Regular

Joined: Tue Nov 23, 2004 7:42 am
Posts: 82
Location: London, England
Sorry, I've not used Sun Appserver and only ever used iPlanet 6.0 under Solaris.

Do you have the same issues with the libraries in WEB-INF/lib?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 9:02 am 
Regular
Regular

Joined: Tue Nov 23, 2004 7:42 am
Posts: 82
Location: London, England
OK OK OK OK OK!

I just reminded myself of something. However this may only apply to Tomcat because of the way it's classloaders work. I discovered this last week with hibernate2.jar.

You may have to have hibernate3.jar in WEB-INF/lib so that it can find hibernate.cfg.xml in the classpath (WEB-INF/classes).

hth,

Rilux


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 9:07 am 
Beginner
Beginner

Joined: Tue Feb 01, 2005 8:38 am
Posts: 38
Rilux wrote:
OK OK OK OK OK!

I just reminded myself of something. However this may only apply to Tomcat because of the way it's classloaders work. I discovered this last week with hibernate2.jar.

You may have to have hibernate3.jar in WEB-INF/lib so that it can find hibernate.cfg.xml in the classpath (WEB-INF/classes).

hth,

Rilux


At the moment I don't have any web-apps in the application so there's no need to have jars in web-inf/lib. I'm just trying to get my session beans working with a test client before moving on to integrating it with a web tier.

The stacktrace for the Error is...
Code:
java.lang.NoClassDefFoundError
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1054)
        at com.myapp.dataLayer.DataManager.<init>(DataManager.java:111)
        at com.myapp.dataLayer.DataManager.getInstance(DataManager.java:58)
        at com.myapp.servicesLayer.SBApplicationMetaDataBean.<init>(SBApplicationMetaDataBean.java:64)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
        at java.lang.Class.newInstance0(Class.java:308)
        at java.lang.Class.newInstance(Class.java:261)
        at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:482)
        at com.sun.ejb.containers.StatelessSessionContainer.access$000(StatelessSessionContainer.java:68)
        at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:735)
        at com.sun.ejb.containers.util.pool.NonBlockingPool.getObject(NonBlockingPool.java:176)
        at com.sun.ejb.containers.StatelessSessionContainer.getContext(StatelessSessionContainer.java:458)
        at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:495)
        at com.myapp.SBApplicationMetaDataBean_EJBObjectImpl.getMessage(SBApplicationMetaDataBean_EJBObjectImpl.java:27)
        at com.myapp.servicesLayer._SBApplicationMetaDataBean_EJBObjectImpl_Tie._invoke(Unknown Source)
        at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatchToServant(GenericPOAServerSC.java:569)
        at com.sun.corba.ee.internal.POA.GenericPOAServerSC.internalDispatch(GenericPOAServerSC.java:211)
        at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatch(GenericPOAServerSC.java:113)
        at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:275)
        at com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProcessor.java:83)
        at com.iplanet.ias.corba.ee.internal.iiop.ServicableWrapper.service(ServicableWrapper.java:25)
        at com.iplanet.ias.util.threadpool.FastThreadPool$ThreadPoolThread.run(FastThreadPool.java:288)
        at java.lang.Thread.run(Thread.java:534)



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