0

I'm migrating a project that was running on Tomcat 8 to Weblogic. I am using Hibernate + JPA 2. When I deploy in weblogic got the following error:

Failure occurred in the execution of deployment request with ID "26012160125422" for task "114". Error is: "weblogic.application.ModuleException: java.lang.NoSuchMethodError: javax.persistence.JoinTable.indexes()[Ljavax/persistence/Index;"

weblogic.application.ModuleException: java.lang.NoSuchMethodError: javax.persistence.JoinTable.indexes()[Ljavax/persistence/Index

Environment
- Java: jdk1.8.0_60
- Weblogic: 12.1.3
- hibernate-entitymanager: 4.3.1.Final
- hibernate-core: 4.3.1.Final
- javaee-api: 7.0

pom.xml

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.3.1.Final</version>
    </dependency>        
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.3.1.Final</version>         
    </dependency>
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>sqljdbc4</artifactId>
        <version>4.0</version>
    </dependency>    
</dependencies>

Thiago
  • 3
  • 4

1 Answers1

0

It is strange that you use javaee-api-7.0.jar, Hibernate 4 has hibernate-jpa-2.1-api-1.0.0.Final.jar as a dependency. But it is not a reason of the error.

JoinTable.indexes() was added with Java Persistence 2.1. So you just have an old jar with JoinTable annotation in the classpath (in the Weblogic default lib folders).

To check where is this jar, run this code before the Hibernate configuration code

URL joinTableUrl = Thread.currentThread().getContextClassLoader()
    .getResource(
    "javax/persistence/JoinTable.class");
System.out.println(joinTableUrl);

To check JoinTable has indexes() method

Class<?> joinTable = Thread.currentThread().getContextClassLoader()
        .loadClass(JoinTable.class.getName());

System.out.println(Arrays.asList(joinTable.getDeclaredMethods()));
v.ladynev
  • 19,275
  • 8
  • 46
  • 67