2

I am running a web application with hibernate and got stuck at this exception.

 ... 34 more 18:50:02,573 WARN [AbstractExceptionHandler] Unhandled exception javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class com.package.util.HibernateUtil at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:295) at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)....... 
2
  • give the whole stacktrace, and the HibernateUtil class code Commented Apr 14, 2011 at 14:01
  • Yeah, and check your static code/static field initializers in the com.package.sit.util.HibernateUtil - that's where the problem is. Commented Apr 14, 2011 at 14:04

3 Answers 3

1

Your code is trying to load the definition of com.package.sit.util.HibernateUtil class but can't find the definition of that class.

This kind of error is usually related to class loading issues that prevents a JAR being loaded. Check if you have all required libraries in the CLASSPATH.

Sign up to request clarification or add additional context in comments.

1 Comment

Problem solved. I am using DB2 database and JBoss server for my application. DB2 drivers were missing in server.
0

first try to add these .jar slf4j-api.jar and slf4j-log4j12.jar because hibernate internally use these jar.

if it is not working then

follow these step for netbeans

Step 1. delete project from the netbean but not the original file(Dont check the box which is asking for deleting the project from original location) Step 2. delete dist and build folder form your project folder step 3. create new project with existing source code. step 4. add the required libraries. now built again. now run.

i checked it for my project it working for me.

Comments

0

I went through the same exact error (and misleading/useless stack trace) only to discover the solution was very simple:

Copy ojdbc14.jar to %CATALINA_HOME%\lib.

This breakthrough discovery was made possible thanks to this Using Hibernate with Tomcat article.

But... if I were more focused, I would have looked way higher at the very beginning of the log:

Jan 14, 2013 07:29:17 AM org.hibernate.connection.DriverManagerConnectionProvider configure SEVERE: JDBC Driver class not found: oracle.jdbc.driver.OracleDriver java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver 

Moral of the story: Sometimes it pays not to look only at the point where the exception occurs but rather much much earlier in the log.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.