title: buildSessionFactory() fails - Could not initialize class HibernateUtil
body: <p>I am trying to use buildSessionFactory method but simply it doesn't work. It is very bizarre, since it was working for me with different example a few days ago. I google'd how to replace it with different solution but none worked so far, I am fairly new to Hibernate, so it's quite possible, that something else is crashing but my understanding of error messages tells me it must be it. This how I use it:</p>
  
  <pre><code>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);
          }
      }
  </code></pre>
  
  <p>but all error messages eventually point to:</p>
  
  <pre><code>return new Configuration().configure().buildSessionFactory();
  </code></pre>
  
  <p>and say:</p>
  
  <p>java.lang.NoClassDefFoundError: Could not initialize class com.xxx.xxx.xxx.HibernateUtil (sorry, I had to hide names of those packages)</p>
  
  <p>What can I use instead of this solution or how do I fix it?</p>