Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.2.1
Mapping documents: hibernate.cfg.xml
Code between sessionFactory.openSession() and session.close():
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
SimpleDateFormat dateFormatter = new SimpleDateFormat("dd.MM.yyyy");
try {
System.out.println("----------- EventManagerServlet - 1");
// Begin unit of work
HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();
System.out.println("----------- EventManagerServlet - 2");
// Write HTML header
PrintWriter out = response.getWriter();
out.println("<html><head><title>Event Manager</title></head><body>");
Full stack trace of any exception that occurs:
INFO: Server startup in 1265 ms
----------- EventManagerServlet - 1
----------- HibernateUtil - 1
Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
Feb 26, 2007 7:08:03 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet EventManagerServlet threw exception
java.lang.ExceptionInInitializerError
at util.HibernateUtil.<clinit>(HibernateUtil.java:25)
at events.EventManagerServlet.doGet(EventManagerServlet.java:22)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
at util.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 17 more
Name and version of the database you are using: OracleEX
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
G'Day guys,
I was able to get the hibernate 1st tutorial wokrin fine. Was using OracleEX as the DB and everything went smooth. Then i decided to try the servlet. I downloaded and installed apache and eclipse plugin and the i tested it with a basic servlet which just outputs text and it works fine, but as soon as i try to do this in my servlet 'HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();' it throws the exception 'Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration'. Now the actual line that throws the error is the HibernateUtil class and is the 2nd line here :-
System.out.println("----------- HibernateUtil - 1");
Configuration conf = new Configuration();
System.out.println("----------- HibernateUtil - 2");
conf.addFile("../hibernate.cfg.xml");
System.out.println("----------- HibernateUtil - 3");
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = conf.configure().buildSessionFactory();
System.out.println("----------- HibernateUtil - 4");
"----------- HibernateUtil - 2" is never outputted to the screen.
I have checked all the references. It even displays the correct package 'org.hibernate.cfg.Configuration' when i hover my mouse over the code in Eclipse. I have removed the 'hibernate3.jar' file and re-added it but nothing seems to work. I cannot understand why this exception is occurring.
PLEASE help me out here guys. Any sort of help will be highly appreciated.
thanks,
pix.