Milleniumlegend
IS-IT--Management
- Dec 16, 2003
- 135
java.lang.NoClassDefFoundError: FirstExample
Exception in thread "main"
I am running the following Hibernate code from Eclipse and getting the error. Does anyone know what could be the problem.
All other java code works on the Eclipse IDE except this one. So I guess the classpath should have been set properly.
Exception in thread "main"
I am running the following Hibernate code from Eclipse and getting the error. Does anyone know what could be the problem.
All other java code works on the Eclipse IDE except this one. So I guess the classpath should have been set properly.
Code:
package roseindia.tutorial.hibernate;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
/**
* @author Deepak Kumar
*
* [URL unfurl="true"]http://www.roseindia.net[/URL]
* Hibernate example to inset data into Deals table
*/
public class FirstExample {
public static void main(String[] args) {
Session session = null;
try{
// This step will read hibernate.cfg.xml and prepare hibernate for use
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
//Create new instance of Contact and set values in it by reading them from form object
System.out.println("Inserting Record");
Deals deal = new Deals();
deal.setId(6);
deal.setResultID(9999);
deal.setDeal("This is a latest test deal");
session.save(deal);
System.out.println("Done");
}catch(Exception e){
System.out.println(e.getMessage());
}finally{
// Actual contact insertion will happen at this step
session.flush();
session.close();
}
}
}