title: java.lang.NoClassDefFoundError: Could not initialize class util.HibernateUtil
body: <p>I'm a newbie in JavaEE development and I'm discovering the frameworks Spring and Hibernate 3 . 
  I'm trying to create a basic app working with these frameworks , But during the running , I get this exception : </p>
  
  <pre><code> oct. 28, 2015 9:45:36 PM org.apache.catalina.core.StandardWrapperValve invoke
  Grave: Servlet.service() for servlet [action] in context with path [/TestSpringHibernateGestionProduit] threw exception [Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class util.HibernateUtil] with root cause
  java.lang.NoClassDefFoundError: Could not initialize class util.HibernateUtil
      at dao.ProduitImplDataBase.getAllProduit(ProduitImplDataBase.java:40)
      at service.ProduitImplMetier.getAllProduit(ProduitImplMetier.java:31)
      at Controller.ProduitController.pageIndex(ProduitController.java:23)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
      at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:439)
      at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:427)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>And here's the HibernteUtil.java file : </p>
  
  <pre><code>package util;
  
  
  
  import org.hibernate.*;
  import org.hibernate.cfg.*;
  
  public class HibernateUtil {
  
      private static final SessionFactory sessionFactory = buildSessionFactory();
  
      private static SessionFactory buildSessionFactory() {
          try {
              // Create the SessionFactory from hibernate.cfg.xml
              return new Configuration().configure().buildSessionFactory();
          }
          catch (Throwable ex) {
              // Make sure you log the exception, as it might be swallowed
              System.err.println("Initial SessionFactory creation failed." + ex);
              throw new ExceptionInInitializerError(ex);
          }
      }
  
      public static SessionFactory getSessionFactory() {
          return sessionFactory;
      }
  
  }
  </code></pre>
  
  <p>I would like to know the source of the error and a solution to solve it. 
  Thank you so much </p>
  
  <p>Kind Regards </p>