title: java.lang.NoClassDefFoundError: org/hibernate/cfg/AnnotationConfiguration
body: <p>I've created a web dynamic project, and want to use <code>Hibernate</code> with it.</p>
  <p>Then, I used the <code>Hibernate Code Generation</code> to generate classes code, and I created a class <code>HibernateUtil</code> where I initialize <code>SessionFactory</code>.</p>
  <pre><code>public class HibernateUtil {
      private static final SessionFactory sessionFactory = buildSessionFactory();
      
      private static SessionFactory buildSessionFactory(){
          try{
              SessionFactory sessionFactory = 
                      new AnnotationConfiguration().configure().buildSessionFactory();
              return sessionFactory;
          }catch(Exception ex){
              ex.printStackTrace();
              throw new ExceptionInInitializerError(ex);
          }
      }
      
      public static SessionFactory getSessionFactory() {
          return sessionFactory;
      }
      
      public static void shutdown() {
          getSessionFactory().close();
      }
  }
  </code></pre>
  <p>And another class <code>HibernateSessionFactoryListener</code> :</p>
  <pre><code>public class HibernateSessionFactoryListener implements ServletContextListener{
  
      @Override
      public void contextInitialized(ServletContextEvent arg0) {
          Session session = HibernateUtil.getSessionFactory().openSession();
          System.out.println(&quot;\n Context Initilaise \n&quot;);
      }
  
      @Override
      public void contextDestroyed(ServletContextEvent arg0) {
          HibernateUtil.shutdown();
          System.out.println(&quot;\n Context Detruit \n&quot;);
      }
  
  }
  </code></pre>
  <p>When I run my project I get this error message :</p>
  <pre><code>java.lang.NoClassDefFoundError: org/hibernate/cfg/AnnotationConfiguration
      at com.hibernate.HibernateUtil.buildSessionFactory(HibernateUtil.java:28)
      at com.hibernate.HibernateUtil.&lt;clinit&gt;(HibernateUtil.java:11)
      at com.hibernate.HibernateSessionFactoryListener.contextInitialized(HibernateSessionFactoryListener.java:12)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
      at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:744)
  Caused by: java.lang.ClassNotFoundException: org.hibernate.cfg.AnnotationConfiguration
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
      ... 12 more
  </code></pre>
  <p>How can I solve this problem ?</p>
  <h1>Edit 1 :</h1>
  <p>This is my Java Build Path :</p>
  <p><img src="https://i.stack.imgur.com/eUmAu.jpg" alt="enter image description here" /></p>