title: Hibernate 5 - java.lang.NoSuchMethodError: javax.persistence.Table.indexes()
body: <p>I'm trying to test some POJOs with hibernate annotations and I'm getting the same error on and on. I used the same configuration in another project and it all worked fine. I tested the jdbc connection that is used when the hib objects are tested - and the connction works fine. </p>
  
  <p>I have found a few other questions asked about the same error but nothing was helpful.</p>
  
  <p>The code in testing class with main method:</p>
  
  <pre><code>public static void main(String[] args) {
  
      SessionFactory factory = new Configuration()
              .configure("hibernate.cfg.xml")
              .addAnnotatedClass(Item.class)
              .buildSessionFactory();
  
      //create session
      Session session = factory.getCurrentSession();
  
      try {
  
          session.beginTransaction();
  
          List&lt;Item&gt; items = session.createQuery("from items").list();
  </code></pre>
  
  <p>The POJO with hibernate annotations:</p>
  
  <pre><code>@Entity
  @Table(name="items")
  public class Item {
  
      @Id
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      @Column(name="id")
      private int id;
  
      @Column(name="name")
      private String name;
  
      @Column(name="price")
      private double price;
  
      @Column(name="stock")
      private int stock;
  
      public Item() {
      }
  
      public Item(String name, double price) {
      this.name = name;
      this.price = price;
      }
  </code></pre>
  
  <p>Below there are getters and setters for each entity.</p>
  
  <p>The file hibernate.cfg.xml has the same configuration as the same file in another project where the connection and hibernate code work perfectly fine - as wrote abobe, the connection was tested in a separate class.</p>
  
  <p>The jars I'm using (all added to class path):</p>
  
  <ul>
  <li>antlr-2.7.7.jar byte-buddy-1.8.0.jar</li>
  <li>classmate-1.3.0.jar</li>
  <li>dom4j-1.6.1.jar </li>
  <li>hibernate-commons-annotations-5.0.3.Final.jar</li>
  <li>hibernate-core-5.3.0.Final.jar </li>
  <li>hibernate-jpa-2.0-api-1.0.0.Final.jar</li>
  <li>jandex-2.0.3.Final.jar </li>
  <li>javassist-3.22.0-GA.jar</li>
  <li>javax.persistence-api-2.2.jar</li>
  <li>jboss-logging-3.3.2.Final.jar</li>
  <li>jboss-transaction-api_1.2_spec-1.0.1.Final.jar</li>
  <li>mysql-connector-java-8.0.11.jar</li>
  </ul>
  
  <p>The error that I mentioned in the title mentions a line in my code which is a line in the first code snipet where .buildSessionFactory() occurs.</p>