-->
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.  [ 4 posts ] 
Author Message
 Post subject: Absurd NoClassDefFoundError: org/hibernate/cfg/Configuration
PostPosted: Mon Feb 26, 2007 11:48 am 
Newbie

Joined: Tue Feb 20, 2007 6:54 am
Posts: 7
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 26, 2007 12:01 pm 
Beginner
Beginner

Joined: Sat Dec 16, 2006 1:52 pm
Posts: 40
Have you added the hibernate3.jar to your runtime classpath?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 26, 2007 2:23 pm 
Newbie

Joined: Tue Feb 20, 2007 6:54 am
Posts: 7
It's in the build path. (ie: when I select the Project Properties -> Java build path -> Libraries it is present there).
How do I add it to the runtime classpath?
And I didn't do anythin different in the first tutorial (which is a console application) and that's working fine.
The current project is a tomcat project and the class is a servlet (if that helps).
And another thing is that I'm NOT using ant here.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 04, 2007 8:05 am 
Newbie

Joined: Tue Feb 20, 2007 6:54 am
Posts: 7
hey guys, i'm still stuck here.. any sort of help here would be greatly appreciated.


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