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: java.lang.NoClassDefFoundError
PostPosted: Wed Jan 04, 2006 3:01 pm 
Newbie

Joined: Wed Jan 04, 2006 2:57 pm
Posts: 3
I'm getting a NoClassDefFoundError exception when building sessino factory

13:48:14,887 [http-8080-Processor24 com.ecredit.ecdata.util.HibernateUtil] exception caught while instantiating session factory
java.lang.NoClassDefFoundError
at org.hibernate.tuple.EntityMetamodel.class$(EntityMetamodel.java:41)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:122)
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:215)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1154)


what could be the problem?
thanks,


Top
 Profile  
 
 Post subject: Check your classpath.
PostPosted: Wed Jan 04, 2006 3:11 pm 
Newbie

Joined: Wed Jan 04, 2006 12:39 pm
Posts: 9
You probably don't have all of the required jar files on your classpath.

Check out the list of needed libraries in section 1.2 of the introduction (http://www.hibernate.org/hib_docs/v3/reference/en/html/tutorial.html#tutorial-firstapp)

Also, see the FAQ here: http://hibernate.org/116.html#A2


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 3:34 pm 
Newbie

Joined: Wed Jan 04, 2006 2:57 pm
Posts: 3
thanks, let me try.


Top
 Profile  
 
 Post subject: Hello I think ur using Hibernate Util class
PostPosted: Wed Jan 04, 2006 3:35 pm 
Newbie

Joined: Tue Jan 03, 2006 3:01 pm
Posts: 1
[quote="berserker"]I'm getting a NoClassDefFoundError exception when building sessino factory

I think ur using Hibernate Util class i.e provided under Hibernate reference manual while creating session factory.

if ur following the above ,
u should follow the below u should solve ur probelm.
U can place Hibernate Util class Under a Package.

example:-
<code>
package my.pack;
import org.hibernate.*;
import org.hibernate.cfg.*;

public class HibernateUtil {

private static Log log = LogFactory.getLog(HibernateUtil.class);

private static final SessionFactory sessionFactory;

static {
try {
// Create the SessionFactory
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
log.error("Initial SessionFactory creation failed.", ex);
throw new ExceptionInInitializerError(ex);
}
}

public static final ThreadLocal session = new ThreadLocal();

public static Session currentSession() {
Session s = (Session) session.get();
// Open a new Session, if this Thread has none yet
if (s == null) {
s = sessionFactory.openSession();
session.set(s);
}
return s;
}

public static void closeSession() {
Session s = (Session) session.get();
if (s != null)
s.close();
session.set(null);
}
}
</code>

compile the above program by using >
after setting the classpath to all required jar files and ur current working directory.
and the issue javac -d . HibernateUtil.java


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 3:58 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Stop spreading this out-of-date HibernateUtil, it is not necessary, and the simple 5-line version provided in the first chapter of the Hibernate reference documentation works perfectly.


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.