Reputation: 23352
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).......
Upvotes: 2
Views: 19353
Reputation: 8157
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
.
Upvotes: 1
Reputation: 4693
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.
Upvotes: 0
Reputation: 669
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.
Upvotes: 0