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

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

When integrating redis with springboot, an error is reported when introducing the jar package:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-12-13 15:56:24.872 ERROR 24864 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

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

    org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration$PoolBuilderFactory.getPoolConfig(LettuceConnectionConfiguration.java:188)

The following method did not exist:

    org.apache.commons.pool2.impl.GenericObjectPoolConfig.setMaxWait(Ljava/time/Duration;)V

The calling method's class, org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration$PoolBuilderFactory, was loaded from the following location:

    jar:file:/D:/develop_toops/maven/maven_repository/org/springframework/boot/spring-boot-autoconfigure/2.6.1/spring-boot-autoconfigure-2.6.1.jar!/org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration$PoolBuilderFactory.class

The called method's class, org.apache.commons.pool2.impl.GenericObjectPoolConfig, is available from the following locations:

    jar:file:/D:/develop_toops/maven/maven_repository/org/apache/commons/commons-pool2/2.6.0/commons-pool2-2.6.0.jar!/org/apache/commons/pool2/impl/GenericObjectPoolConfig.class

The called method's class hierarchy was loaded from the following locations:

    org.apache.commons.pool2.impl.GenericObjectPoolConfig: file:/D:/develop_toops/maven/maven_repository/org/apache/commons/commons-pool2/2.6.0/commons-pool2-2.6.0.jar
    org.apache.commons.pool2.impl.BaseObjectPoolConfig: file:/D:/develop_toops/maven/maven_repository/org/apache/commons/commons-pool2/2.6.0/commons-pool2-2.6.0.jar
    org.apache.commons.pool2.BaseObject: file:/D:/develop_toops/maven/maven_repository/org/apache/commons/commons-pool2/2.6.0/commons-pool2-2.6.0.jar


Action:

Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration$PoolBuilderFactory and org.apache.commons.pool2.impl.GenericObjectPoolConfig

Solution:

Delete the version number in the dependency, and springboot will automatically match the appropriate version

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-pool2</artifactId>
</dependency>