0

I have an error

Caused By: java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;

when project deployed in WebLogic 12C with project is configured in Spring boot,maven ad Eclipse.

Here is my POM.XML format

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

<groupId>com.project</groupId>
<artifactId>project</artifactId>
<version>0.1.0</version>
<packaging>war</packaging>



<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.1.RELEASE</version>
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <!-- JPA Data (We are going to use Repositories, Entities, Hibernate, etc...) -->

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <!-- Use MySQL Connector-J -->

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.5</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

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

    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20080701</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.8.7</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.6.1</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.6.1</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>

    <!-- <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.1-api</artifactId>
        <version>1.0.0.Final</version>
    </dependency> -->

</dependencies>

<properties>
    <java.version>1.7</java.version>
</properties>

<build>
    <finalName>project</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

Please let me know any one know the solution.

  • Please provide a stack trace. A possible reason for the problem could be that the Java version Weblogic runs on is too old. Another reason could be that a classloader loads javax.persistence.Table from a third party source. – mm759 Mar 15 '17 at 07:22
  • Your Weblogic probably still uses an old version of JPA. indexes was introduced in JPA 2.1 (Java EE 7). – JB Nizet Mar 15 '17 at 07:25
  • Configure your app (or web logic) to prefer classes from the application and not from the server. Weblogic has its own JPA implementation and api and that takes precedence over the classes from the application. – M. Deinum Mar 15 '17 at 07:25
  • 2
    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) – Neil Stockton Mar 15 '17 at 07:27
  • Ah, right. The class is not part of Java SE. – mm759 Mar 15 '17 at 07:28

1 Answers1

1
  1. First of all, Spring Boot with Weblogic, I think here you are mixing two web containers (probably wrong approach).

  2. Regarding only to JPA exception is because is expecting JPA 2.1 and WLS 12.1.3 has support of it, but not by default. It is necessary to enable it (it is not in the classpath).

http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/wls/12c/01-06-004-JavaEE7andWebLogicServer/javaee7.html

devwebcl
  • 2,866
  • 3
  • 27
  • 46