I have been expermenting with Hibernate, and found that when trying to run app getting a NoClassDefFoundError. Now I know that this may seem like a typical classpath issue, but please read on!
I have un-jar'd the Hibernate2.jar (which is in the ext directory under JRE install) and found that the Class net.sf.hibernate.cfg.Configuration is there.
(By the way this is the class that it recons it can't find!!!)
Hibernate version: 2.0.3
The code that I am using was taken from the ONJava tut:
// 2. Fire up Hibernate
Configuration cfg = new onfiguration().addClass(Product.class);
SessionFactory sf = cfg.buildSessionFactory();
System.out.println(p);
// 3. Open Session
Session sess = sf.openSession();
// 4. Save Product and close Session
Transaction t = sess.beginTransaction();
sess.save(p);
t.commit();
sess.close();
Stack Trace:
C:\database\HibernateArticle\src>java test.InsertProduct Milk 100 1.99
Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/hibernate/cfg/
Configuration
at test.InsertProduct.main(InsertProduct.java:23)
Database: hsqldb (latest stable build)
Any help would be greatly appreciated! if there is anything I missed just let me know.
|