title: Getting an Error Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ClassLoaderDelegate
body: <p>I am trying to run this CRUD operations code using Hibernate. I am unable to fix the error. </p>
  
  <p>I have tried with different Jars and looked for solutions online and failed to get rid of this error.</p>
  
  <p>The following are the classes and configuration files that matter.</p>
  
  <pre><code>public class TrainDAO {
  
      Configuration c = new Configuration().configure("hibernate.cfg.xml");
      SessionFactory sf = c.buildSessionFactory();
      Session s = sf.openSession();
  
      public void insert(TrainDetails trainDetails)
      {
          s.beginTransaction();
          s.save(trainDetails);
          s.getTransaction().commit();
      }
  
      public void delete(int train_number)
      {
          s.beginTransaction();
          TrainDetails td = s.get(TrainDetails.class, train_number);
          s.delete(td);
  
          s.getTransaction().commit();
      }
  
      public List&lt;TrainDetails&gt; fetch_by_train_number(int train_number)   {
          s.beginTransaction();
          List&lt;TrainDetails&gt; list = s.createQuery("from TrainDetails").list();
  
          s.getTransaction().commit();
          return list;
      }
  
      public List&lt;TrainDetails&gt; fetch_by_train_name(String train_name)    {
          s.beginTransaction();
          List&lt;TrainDetails&gt; list = s.createQuery("from TrainDetails").list();
  
          s.getTransaction().commit();
          return list;
      }
  
      public void update(int train_number, String train_type) {
          TrainDetails trainDetails = new TrainDetails();
          trainDetails.setTrain_number(train_number);
          trainDetails.setTrain_type(train_type);
  
          TrainDetails list = (TrainDetails) s.get(TrainDetails.class, train_number);
          s.update(trainDetails);
  
          s.getTransaction().commit();
      }
  }
  
  public class TrainDriver {
      public static void main(String[] args) {
  
          TrainDetails train = new TrainDetails();
          Scanner sc = new Scanner(System.in);
  
          int choice = sc.nextInt();
  
          do {
              switch (choice) {
              case 1:
                  train.setTrain_number(sc.nextInt());
                  train.setTrain_name(sc.next());
                  train.setOrigin(sc.next());
                  train.setDestination(sc.next());
                  train.setDistance(sc.nextInt());
                  train.setFare(sc.nextInt());
                  train.setTrain_type(sc.next());
                  new TrainDAO().insert(train);
                  break;
              case 2:
                  int train_number = sc.nextInt();
                  String train_name = sc.next();
  
                  List&lt;TrainDetails&gt; list = new TrainDAO().fetch_by_train_number(train_number);
                  List&lt;TrainDetails&gt; list1 = new TrainDAO().fetch_by_train_name(train_name);
  
                  break;
              case 3:
                  int train_number1 = sc.nextInt();
                  String train_type = sc.next();
  
                  new TrainDAO().update(train_number1, train_type);
                  break;
              case 4:
                  int train_number2 = sc.nextInt();
  
                  new TrainDAO().delete(train_number2);
                  break;
              case 5:
                  System.exit(0);
              }
  
          } while (true);
      }
  }
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
      &lt;session-factory&gt;
          &lt;property name="hibernate.connection.password"&gt;root&lt;/property&gt;
          &lt;property name="hibernate.connection.username"&gt;SYSTEM&lt;/property&gt;
          &lt;property name="hibernate.connection.driver_class"&gt;oracle.jdbc.driver.OracleDriver&lt;/property&gt;
          &lt;property name="hibernate.connection.url"&gt;jdbc:oracle:thin:@localhost:1521/XE&lt;/property&gt;
          &lt;property name="hibernate.hbm2ddl.auto"&gt;update&lt;/property&gt;
          &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.OracleDialect&lt;/property&gt;
          &lt;property name="show_sql"&gt;true&lt;/property&gt;
          &lt;mapping resource="simple.hbm.xml" /&gt;
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  
  Apart from this I have a POJO class and hbm.xml which points to the tables created in OracleSQL. When i run this code as Run As -&gt; JAVA Application, i get a classLoaderDelegate error.
  
  The following is the stacktrace of the error - 
  
  Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ClassLoaderDelegate
      at org.hibernate.boot.internal.MetadataBuilderImpl.&lt;init&gt;(MetadataBuilderImpl.java:127)
      at org.hibernate.boot.MetadataSources.getMetadataBuilder(MetadataSources.java:135)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:655)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
      at com.demo.dao.TrainDAO.&lt;init&gt;(TrainDAO.java:15)
      at com.demo.driver.TrainDriver.main(TrainDriver.java:37)
  Caused by: java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.ClassLoaderDelegate
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      ... 6 more
  </code></pre>
  
  <p>I have tried all the options and methods that I could find online. The basic difficulty is in understanding the error. I am unable to find <code>ClassLoaderDelegate</code> nor able to resolve this from the line numbers in my code.</p>
  
  <p>Let me know where I have gone wrong.</p>