Rômulo Sorato
Rômulo Sorato

Reputation: 1651

Error starting spring boot "An attempt was made to call a method that does not exist"

When i run the spring boot app, intellij returns me an error:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

org.hibernate.envers.boot.internal.TypeContributorImpl.contribute(TypeContributorImpl.java:30)

The following method did not exist:

org.hibernate.boot.model.TypeContributions.contributeJavaTypeDescriptor(Lorg/hibernate/type/descriptor/java/spi/JavaTypeDescriptor;)V

The method's class, org.hibernate.boot.model.TypeContributions, is available from the following locations:

jar:file:/C:/Users/romul/.m2/repository/org/hibernate/hibernate-core/5.4.6.Final/hibernate-core-5.4.6.Final.jar!/org/hibernate/boot/model/TypeContributions.class
jar:file:/C:/Users/romul/.m2/repository/org/hibernate/orm/hibernate-core/6.0.0.Alpha2/hibernate-core-6.0.0.Alpha2.jar!/org/hibernate/boot/model/TypeContributions.class

It was loaded from the following location:

file:/C:/Users/romul/.m2/repository/org/hibernate/hibernate-core/5.4.6.Final/hibernate-core-5.4.6.Final.jar

Action:

Correct the classpath of your application so that it contains a single, compatible version of org.hibernate.boot.model.TypeContributions

This could be a conflict im my pom.xml?

This is my pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.produtos</groupId>
    <artifactId>api-rest</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>api-rest</name>
    <description>Demo project for Spring Boot</description>

    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>


    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>12</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.2.8</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.26.0-GA</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate.orm</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>6.0.0.Alpha2</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.4.8.Final</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.4.0-b180830.0359</version>
        </dependency>

    </dependencies>

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


</project>

How i can fix it?

Upvotes: 19

Views: 107943

Answers (8)

SalutonMondo
SalutonMondo

Reputation: 709

delete the repository under maven which cause the problem (eg. C:\Users\Administrator.m2\repository\xerces), then run it again.

Upvotes: 0

BoitsovRich
BoitsovRich

Reputation: 1

this is how IDEA helped me file -> Invalidate caches

after all dependencies are updated the error is cleared

Upvotes: 0

Neeraj Sharma
Neeraj Sharma

Reputation: 473

Delete your .m2 folder in your user directory, e.g. c:\users\<user-name>\.m2 and then run maven install. This will fix your classpath problem.

Upvotes: 2

Muathe Jamil
Muathe Jamil

Reputation: 11

I Got the same problem, I was building multi-module project in the parent pom file was the dependency spring-boot-starter-parent and it is also exist in the children poms, so I delete the one in the parent and the problem disappeared.

Upvotes: 0

Muhammad Numan
Muhammad Numan

Reputation: 249

Here is the issue

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>5.3.18</version>
    </dependency>

I use the quick solution in my application for adding a new dependency then I rerun the java application then my error occur. After checking I found this dependency is the reason for the error. Just remove it and solve the error.

Upvotes: 0

Bukunmi
Bukunmi

Reputation: 2574

In my case, i took the following steps.

  1. I deleted the .m2 folder in c:\users\ (Note its is hidden).
  2. I was using spring-boot-starter-data-jpa and spring-boot-starter-data-rest so i removed the data-rest dependency completely
  3. Close the project and open again (With internet connection), so the required dependency files will be downloaded again.

Upvotes: 4

khaoula1305
khaoula1305

Reputation: 74

Action:

Correct the classpath of your application so that it contains a single, compatible version of hibernate.

Upvotes: 0

Wim Deblauwe
Wim Deblauwe

Reputation: 26878

You should not specify the version of Hibernate to use as the spring-boot-starter-data-jpa dependency takes care of that.

If you run mvn dependency:tree | grep hibernate, you see that 2 versions of hibernate are included:

16:20 $ mvn dependency:tree | grep hibernate
[INFO] |  |  \- org.hibernate.validator:hibernate-validator:jar:6.0.17.Final:compile
[INFO] |  +- org.hibernate:hibernate-core:jar:5.4.6.Final:compile
[INFO] +- org.hibernate.orm:hibernate-core:jar:6.0.0.Alpha2:compile
[INFO] |  +- org.hibernate.common:hibernate-commons-annotations:jar:5.1.0.Final:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:5.4.8.Final:compile

It seems the group id changed from org.hibernate to org.hibernate.orm, that is why Maven does not notice it is the same library.

Also the hibernate-entitymanager dependency can be removed.

Upvotes: 16

Related Questions