-2

I was using Hibernate 4.3.6 and used annotations based persistence definition. On tomcat 8.0 it was working fine. But when I deployed in WAS Liberty profile 8.5.5.7 it gave the root cause exception as below, and haven't been able to figure out why. Some on told to upgrade Hibernate to 5.1.0 but did not work. I am using Eclipse for development. I am also using Spring 4.0.1.

Caused by: java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
    at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:936)
    at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:824)
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3788)
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3742)
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1410)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
    at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:343)
    at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:431)
    at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:416)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
    ... 57 more
Alex K
  • 22,315
  • 19
  • 108
  • 236
Jyotibass
  • 1
  • 1
  • 2
  • "Somebody told to upgrade" ... well yes, that method is clearly part of JPA 2.1 and you are NOT using consistent versions of JPA provider and JPA jar (and any "it didn't work" means you didn't upgrade correctly). This has been asked many times before on here, all findable using search. – Neil Stockton May 24 '16 at 08:57

1 Answers1

0

You have an incorrect jar in the WebSphere Liberty class path, with the JPA annotations prior the version 2.1, as @NeilStockton suggested.

Firstly, try to add @Table(indexes = {}) whenever in the source in Eclipse. If it can be imported correctly — you have a correct hibernate-jpa-2.1-api-1.0.0.Final.jar (it is for Hibernate 5) in the class path in Eclipse. Delete @Table(indexes = {}) after that.

To find a jar from which incorrect @Table annotation is loaded, try to execute this code somewhere independent of the Spring configuration. You can use ContextListener for that.

URL url = Thread.currentThread().getContextClassLoader()
    .getResource("javax/persistence/Table.class");
System.out.println(url);
v.ladynev
  • 19,275
  • 8
  • 46
  • 67