title: java.lang.NoClassDefFoundError: Could not initialize class org.com.hibernate.HibernateUtil
body: <p>This is my hibernate util code</p>
  
  <pre><code>public class HibernateUtil {
  
  private static final SessionFactory sessionFactory = buildSessionFactory();
  
  private static SessionFactory buildSessionFactory() {
      try {
          // Create the SessionFactory from hibernate.cfg.xml
          return new AnnotationConfiguration().configure().buildSessionFactory();
      } catch (Throwable ex) {
          System.err.println("Initial SessionFactory creation failed." + ex);
          throw new ExceptionInInitializerError(ex);
      }
  }
  
  public static SessionFactory getSessionFactory() {
      return sessionFactory;
  }
  }
  </code></pre>
  
  <p>this is my hibernate.cfg.xml</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  
  &lt;hibernate-configuration&gt;
  
  &lt;session-factory&gt;
  
      &lt;!-- Database connection settings --&gt;
      &lt;property name="connection.driver_class"&gt;
          oracle.jdbc.OracleDriver
      &lt;/property&gt;
      &lt;property name="connection.url"&gt;
          jdbc:oracle:thin:@127.0.0.1:ABC
      &lt;/property&gt;
      &lt;property name="connection.username"&gt;abc&lt;/property&gt;
      &lt;property name="connection.password"&gt;***&lt;/property&gt;
  
      &lt;!-- JDBC connection pool (use the built-in) --&gt;
      &lt;property name="connection.pool_size"&gt;3&lt;/property&gt;
  
      &lt;!-- SQL dialect --&gt;
      &lt;property name="dialect"&gt;
          org.hibernate.dialect.Oracle10gDialect
      &lt;/property&gt;
  
      &lt;!-- Enable Hibernate's automatic session context management --&gt;
      &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt;
  
      &lt;!-- Disable the second-level cache --&gt;
      &lt;property name="cache.provider_class"&gt;
          org.hibernate.cache.NoCacheProvider
      &lt;/property&gt;
  
      &lt;!-- Echo all executed SQL to stdout --&gt;
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
      &lt;!-- Drop and re-create the database schema on startup --&gt;
      &lt;property name="hbm2ddl.auto"&gt;update&lt;/property&gt;
  
      &lt;mapping class="org.com.tables.User_Details" /&gt;
  &lt;/session-factory&gt;
  
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>and this is the error</p>
  
  <pre><code>java.lang.NoClassDefFoundError: Could not initialize class org.com.hibernate.HibernateUtil
  at org.com.graphDoa.GraphDOA.salaryData(GraphDOA.java:14)
  at org.com.charts.LineChart.generateSalaryPai(LineChart.java:32)
  at com.kogent.action.TestAction.execute(TestAction.java:17)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:399)
  at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:262)
  at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:224)
  at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50)
  at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:507)
  at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
  at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:403)
  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:301)
  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:162)
  at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
  at java.lang.Thread.run(Thread.java:619)
  </code></pre>
  
  <p>can any one help me find out what is this error all about ,am struck like nothing.If this has some thing to do with the libraries or any other thing please suggest.I am using struts 2 for mvc and hibernate 3 for database connection and tomcat 7 as a web server.</p>