I deployed my application to the official server and started getting this error:
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)root cause
javax.servlet.ServletException:
java.lang.NoClassDefFoundError: Could
not initialize class app.HibernateUtil
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.ajax.search_jsp._jspService(search_jsp.java:67)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)root cause
java.lang.NoClassDefFoundError: Could
not initialize class app.HibernateUtil
app.PersistanceHelper.(PersistanceHelper.java:23)
app.SearchBean.(SearchBean.java:26)
org.apache.jsp.ajax.search_jsp._jspService(search_jsp.java:54)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
Before the deployment the app worked fine. My HibernateUtil class was generated by Netbeans wizard. I cannot see where does the problem originate. I spent some time searching for the similar problem in google but the answers found (missing jars, spelling errors, etc) are not applicable in this solution as it works on my PC, just not on the official server. Any thoughts on that? I can add the rest of the sources if needed. Apache Tomcat log does not contain any errors. Thanks for any help.
I think that your class is on the classpath but the
ClassLoaderruns into an error when trying to load the class (as hinted by the message). This typically happens when the class has a static block or static members which use aClassthat can’t found by theClassLoader.In the particular case of this generated
HibernateUtil.java, it should have something like this:So:
try { ... } catch (Throwable t) { ... }in your static block to log the error.