3

I am trying to deploy a JPA 2.1 (Hibernate) project on Weblogic 12.1.3 on Java 8 and getting this error. But works on Tomcat 8.

Caused By: java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
    at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:973)
    at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:824)
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3845)
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3799)
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1412)
    Truncated. see log file for complete stacktrace

pom.xml

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.3.11.Final</version>
    </dependency>

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
    </dependency>


    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.2.0.RELEASE</version>
    </dependency>


   <!--     
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-jpa</artifactId>
        <version>1.8.2.RELEASE</version>
        <exclusions>
            <exclusion>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.0-api</artifactId>
            </exclusion>
        </exclusions>           
    </dependency>
     -->

Update:-

As answered below, JPA 2.1 is not enabled in Weblogic 12.1.3 by default. And can be enabled as explained here http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/wls/12c/01-06-004-JavaEE7andWebLogicServer/javaee7.html#section1

Jay
  • 9,189
  • 12
  • 56
  • 96
  • 1
    possible duplicate of [NoSuchMethodError in javax.persistence.Table.indexes()\[Ljavax/persistence/Index](http://stackoverflow.com/questions/20734540/nosuchmethoderror-in-javax-persistence-table-indexesljavax-persistence-index) – Kumar Abhinav Aug 15 '15 at 16:41
  • @KumarAbhinav I have seen many of those posts but didn't help. – Jay Aug 15 '15 at 17:29

2 Answers2

2

Weblogic is a java-ee application server and comes with the full java-ee stack (and includes so JPA).

Weblogic 12.1.3 comes with jpa 2.1 with eclipselink as provider see here

including hibernate as jpa implementation have so no sense here as the server already come with it's own implmentation (maven scope provided)

I suppose that this dependencies

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>7.0</version>
</dependency>

is so sufficient (jpa 2.1 is part of java-ee 7 stack)

Gab
  • 7,869
  • 4
  • 37
  • 68
  • Here it says you have to enable it (JPA 2.1) explicitly: http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/wls/12c/01-06-004-JavaEE7andWebLogicServer/javaee7.html#section1 – ACV Aug 18 '15 at 15:16
  • In fact weblo 12.1.3 is not fully java-ee 7 certified (see my first link) so I'am not sure that using java-ee 7 api is really safe here, if I were you i would include javaee-api 6 excluding jpa 2.0 and include jpa 2.1 api apart. anyway there is no official api release (https://java.net/jira/browse/JPA_SPEC-60) so you will have to choose this one http://mvnrepository.com/artifact/org.eclipse.persistence/javax.persistence/2.1.0 – Gab Aug 18 '15 at 15:22
  • Many thanks for both of you guys. Those links were very helpful. Once I added those 2.1 jars on classpath, it worked. – Jay Aug 20 '15 at 14:53
1

Could be that Weblogic is using its own library for JPA, which is older than yours. Could be that JPA 2.1 wasn't enabled during setup. You need to configure the server to enforce your libraries instead of those provided by WLS. How to configure prefer application packages

ACV
  • 9,964
  • 5
  • 76
  • 81