title: Hibernate: javax.persistence.Table.indexes()[Ljavax/persistence/Index
body: <p>My project works fine with Tomcat 7, Tomcat 8, WildFly 8 and WildFly 10. It works with:
  JSF : 2.0
  Hibernate : 4.3.5
   and JDK : 1.7</p>
  
  <p>Knowing that the class <code>EntityDaoInterface</code> is:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>public interface EntityDaoInterface&lt;T, Id extends Serializable&gt;
  {
   public void persist(T entity);
   public void update(T entity);
   public T findById(Id id);
   public void delete(T entity);
   public List&lt;T&gt; findAll();
   public void deleteAll();
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>the class <code>EntityDao.java</code> is:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>public class EntityDao implements EntityDaoInterface&lt;Person, Integer&gt;
  {
  
   private Session currentSession;
   
   private Transaction currentTransaction;
  
   public EntityDao() {
   }
  
   public Session openCurrentSession() {
    currentSession = getSessionFactory().openSession();
    return currentSession;
   }
  
   public Session openCurrentSessionwithTransaction() {
    currentSession = getSessionFactory().openSession();
    currentTransaction = currentSession.beginTransaction();
    return currentSession;
   }
   
   public void closeCurrentSession() {
    currentSession.close();
   }
   
   public void closeCurrentSessionwithTransaction() {
    currentTransaction.commit();
    currentSession.close();
   }
   
   private static SessionFactory getSessionFactory() {
    Configuration configuration = new Configuration().configure();
    StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder()
      .applySettings(configuration.getProperties());
    SessionFactory sessionFactory = configuration.buildSessionFactory(builder.build());
    return sessionFactory;
   }
  
   public Session getCurrentSession() {
    return currentSession;
   }
  
   public void setCurrentSession(Session currentSession) {
    this.currentSession = currentSession;
   }
  
   public Transaction getCurrentTransaction() {
    return currentTransaction;
   }
  
   public void setCurrentTransaction(Transaction currentTransaction) {
    this.currentTransaction = currentTransaction;
   }
  
   public void persist(Person entity) {
    getCurrentSession().save(entity);
   }
  
   public void update(Person entity) {
    getCurrentSession().update(entity);
   }
  
   public void delete(Person entity) {
    getCurrentSession().delete(entity);
   }
  
   @SuppressWarnings("unchecked")
   public List&lt;Person&gt; findAllPersons() {
    List&lt;Person&gt; persons = (List&lt;Person&gt;) getCurrentSession().createQuery("from Person").list();
    return persons;
   }
  
   public Person findPersonById(Integer id) {
    Person person = (Person) getCurrentSession().get(Person.class, id);
    return person; 
   }
   
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>the class <code>EntityService.java</code> is:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>public class EntityService 
  {
  
   private static EntityDao entityDao;
  
   public EntityService() {
    entityDao = new EntityDao();
   }
   
   public void persist(Person entity) {
    entityDao.openCurrentSessionwithTransaction();
    entityDao.persist(entity);
    entityDao.closeCurrentSessionwithTransaction();
   }
  
   public void update(Person entity) {
    entityDao.openCurrentSessionwithTransaction();
    entityDao.update(entity);
    entityDao.closeCurrentSessionwithTransaction();
   }
  
   public void remove(Person entity) {
    entityDao.openCurrentSessionwithTransaction();
    entityDao.delete(entity);
    entityDao.closeCurrentSessionwithTransaction();
   }
  
   public Person findPersonById(int id) {
    entityDao.openCurrentSession();
    Person person = entityDao.findPersonById(id);
    entityDao.closeCurrentSession();
    return person;
   }
  
   public List&lt;Person&gt; findAllPersons() {
    entityDao.openCurrentSession();
    List&lt;Person&gt; persons = entityDao.findAllPersons();
    entityDao.closeCurrentSession();
    return persons;
   }
  
   public void deleteAll() {
    entityDao.openCurrentSessionwithTransaction();
    entityDao.deleteAll();
    entityDao.closeCurrentSessionwithTransaction();
   }
  
   public EntityDao entityDao() {
    return entityDao;
   }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>the file <code>hibernate.cfg.xml</code> is:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  
  &lt;hibernate-configuration&gt;
     &lt;session-factory&gt;
      &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.SQLServer2005Dialect&lt;/property&gt;
      &lt;property name="hibernate.connection.driver_class"&gt;com.microsoft.sqlserver.jdbc.SQLServerDriver&lt;/property&gt;
      &lt;property name="hibernate.connection.url"&gt;jdbc:sqlserver://localhost:1433;database=ccc&lt;/property&gt;
      &lt;property name="hibernate.connection.username"&gt;lm&lt;/property&gt;
      &lt;property name="hibernate.connection.password"&gt;pp&lt;/property&gt;
      &lt;property name="hibernate.hbm2ddl.auto"&gt;update&lt;/property&gt;
      &lt;property name="show_sql"&gt;false&lt;/property&gt;
      &lt;property name="hibernate.current_session_context_class"&gt;thread&lt;/property&gt;
      &lt;mapping class="com.esprit.entity.Book"/&gt;
      &lt;mapping class="com.esprit.entity.Person"/&gt;
     &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>and the jars existed on <code>WEB-INF/lib</code> are:</p>
  
  <p><a href="https://i.stack.imgur.com/nqwBO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nqwBO.png" alt="enter image description here"></a></p>
  
  <p>But, there's a problem with JBoss 7.1. In fact, the following error is displayed. Could you please help me solving this exception.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>08:32:54,297 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "HelloJPAHibernate.war"
  08:33:01,282 INFO  [org.hibernate.annotations.common.Version] (http-localhost-127.0.0.1-8080-1) HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
  08:33:01,290 INFO  [org.hibernate.Version] (http-localhost-127.0.0.1-8080-1) HHH000412: Hibernate Core {4.3.5.Final}
  08:33:01,293 INFO  [org.hibernate.cfg.Environment] (http-localhost-127.0.0.1-8080-1) HHH000205: Loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.h2.Driver, hibernate.service.allow_crawling=false, hibernate.dialect=org.hibernate.dialect.H2Dialect, hibernate.max_fetch_depth=5, hibernate.format_sql=true, hibernate.generate_statistics=true, hibernate.connection.username=sa, hibernate.connection.url=jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE, hibernate.bytecode.use_reflection_optimizer=false, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.pool_size=5}
  08:33:01,297 INFO  [org.hibernate.cfg.Environment] (http-localhost-127.0.0.1-8080-1) HHH000021: Bytecode provider name : javassist
  08:33:01,317 INFO  [org.hibernate.cfg.Configuration] (http-localhost-127.0.0.1-8080-1) HHH000043: Configuring from resource: /hibernate.cfg.xml
  08:33:01,318 INFO  [org.hibernate.cfg.Configuration] (http-localhost-127.0.0.1-8080-1) HHH000040: Configuration resource: /hibernate.cfg.xml
  08:33:01,366 INFO  [org.hibernate.cfg.Configuration] (http-localhost-127.0.0.1-8080-1) HHH000041: Configured SessionFactory: null
  08:33:01,453 WARN  [org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (http-localhost-127.0.0.1-8080-1) HHH000402: Using Hibernate built-in connection pool (not for production use!)
  08:33:01,455 INFO  [org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (http-localhost-127.0.0.1-8080-1) HHH000401: using driver [com.microsoft.sqlserver.jdbc.SQLServerDriver] at URL [jdbc:sqlserver://localhost:1433;database=ccc]
  08:33:01,457 INFO  [org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (http-localhost-127.0.0.1-8080-1) HHH000046: Connection properties: {user=lm, password=****}
  08:33:01,458 INFO  [org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (http-localhost-127.0.0.1-8080-1) HHH000006: Autocommit mode: false
  08:33:01,460 INFO  [org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (http-localhost-127.0.0.1-8080-1) HHH000115: Hibernate connection pool size: 5 (min=1)
  08:33:03,123 INFO  [org.hibernate.dialect.Dialect] (http-localhost-127.0.0.1-8080-1) HHH000400: Using dialect: org.hibernate.dialect.SQLServer2008Dialect
  08:33:03,255 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/HelloJPAHibernate].[Faces Servlet]] (http-localhost-127.0.0.1-8080-1) Servlet.service() for servlet Faces Servlet threw exception: java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
  at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:936) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
  at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:824) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
  at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3788) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
  at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3742) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
  at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1410) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
  at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
  at com.esprit.dao.EntityDao.getSessionFactory(EntityDao.java:48) [classes:]
  at com.esprit.dao.EntityDao.openCurrentSession(EntityDao.java:25) [classes:]
  at com.esprit.dao.EntityService.findAllPersons(EntityService.java:86) [classes:]
  at com.esprit.crud.dynamic.DataModelBeanD.init(DataModelBeanD.java:37) [classes:]
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_55]
  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_55]
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_55]
  at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_55]</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thanks in advance.</p>