hibernate-4.x java playframework-2.0

NoSuchMethodError in javax.persistence.Table.indexes()[Ljavax/persistence/Index


I have a Play Framework application and I was using Hibernate 4.2.5.Final (which is retrieved via the Maven dependency manager). I decided to upgrade to Hibernate 4.3.0.Final, recompile my application successfully, and ran it.

I got the exception below, and haven’t been able to figure out why. I downgraded back to 4.2.5 and this issue did not occur. I then, tried upgrading Hibernate with each Final release after 4.2.5. That is, I went from 4.2.5.Final to 4.2.6.Final, to 4.2.7.Final, to 4.2.8.Final and then to 4.3.Final. The issue does not occur until I upgrade to 4.3.0.Final.

Java version information

java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

And exception:

play.api.UnexpectedException: Unexpected exception[NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:152) ~[play_2.10.jar:2.2.1]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:112) ~[play_2.10.jar:2.2.1]
    at ~[scala-library.jar:na]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:112) ~[play_2.10.jar:2.2.1]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:110) ~[play_2.10.jar:2.2.1]
    at scala.util.Success.flatMap(Try.scala:200) ~[scala-library.jar:na]
Caused by: java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
    at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions( ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
    at org.hibernate.cfg.AnnotationBinder.bindClass( ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue( ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata( ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
    at org.hibernate.cfg.Configuration.secondPassCompile( ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]
    at org.hibernate.cfg.Configuration.buildSessionFactory( ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final]


  • 1

    You’re calling a method that doesn’t exist in the newer version

    Dec 22, 2013 at 22:10


I’ve ran into the same problem. The question here is that play-java-jpa artifact (javaJpa key in the build.sbt file) depends on a different version of the spec (version 2.0 -> "org.hibernate.javax.persistence" % "hibernate-jpa-2.0-api" % "1.0.1.Final").

When you added hibernate-entitymanager 4.3 this brought the newer spec (2.1) and a different factory provider for the entitymanager. Basically you ended up having both jars in the classpath as transitive dependencies.

Edit your build.sbt file like this and it will temporarily fix you problem until play releases a new version of the jpa plugin for the newer api dependency.

libraryDependencies ++= Seq(
javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"),
"org.hibernate" % "hibernate-entitymanager" % "4.3.0.Final"

This is for play 2.2.x. In previous versions there were some differences in the build files.


  • 1

    Awesome, it worked! Thanks. For future reference, here is a link to documentation for excluding transitive dependencies:…

    – musubi

    Dec 27, 2013 at 18:57

  • 4

    thanks! for maven users: it means just dont use <groupId></groupId> <artifactId>jpa-api</artifactId> any more

    – oak

    Jan 21, 2014 at 6:06

  • 4

    For hibernate-jpa-2.0-api Hibernate 4.2.8.Final Version is work 4.3.0.Final also throw an error.

    Jun 12, 2014 at 7:06

  • On Play 2.2.3 libraryDependencies ++= Seq( javaJdbc, javaEbean, cache, javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"), "org.hibernate" % "hibernate-core" % "4.3.0.Final", "org.hibernate" % "hibernate-entitymanager" % "4.3.0.Final", "com.typesafe" %% "play-plugins-mailer" % "2.2.0", "postgresql" % "postgresql" % "9.1-901-1.jdbc4", "" % "guava-base" % "r03", "org.apache.commons" % "commons-io" % "1.3.2" ) is still throwing NoSuchMethodException NoSuchMethodError:javax.persistence.JoinTable.indexes() Anyone knows how to solve?

    Sep 9, 2014 at 13:23

  • Am also facing the same issue with Play 2.3.4 version. Here is the stack trace play.api.UnexpectedException: Unexpected exception[NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;] at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:170) ~[play_2.11-2.3.4.jar:2.3.4 ] at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:130) ~[play_2.11-2.3.4.jar:2.3.4 ] at ~[scala-library-2.11.1.jar:na]

    Sep 10, 2014 at 9:07


Hibernate 4.3 is the first version to implement the JPA 2.1 spec (part of Java EE 7). And it’s thus expecting the JPA 2.1 library in the classpath, not the JPA 2.0 library. That’s why you get this exception: Table.indexes() is a new attribute of Table, introduced in JPA 2.1


  • I was going down the same track but the code where the error happens is calling indexes() on an reference of type org.hibernate.annotations.Table.

    Dec 22, 2013 at 22:21

  • 1

    You’re probably not looking at the right code, then. See…

    – JB Nizet

    Dec 22, 2013 at 22:25

  • 1

    @JBNizet Is JPA 2.1 only available in Java EE 7 and not in SE 7? And I’m guessing JPA 2.0 is available in Java SE 7?

    – musubi

    Dec 23, 2013 at 3:19

  • 2

    @JBNizet so what is the solution. Can I change to java EE to 7 or can i change JPA 2.0 to JPA 2.1?? If I do so gives error..

    Jun 25, 2014 at 13:50

  • 1

    <!–… –> <dependency> <groupId>javax.persistence</groupId> <artifactId>javax.persistence-api</artifactId> <version>2.2</version> </dependency>

    – bula

    Dec 18, 2018 at 6:57


I update my Hibernate JPA to 2.1 and It works.