Spring Boot errors
An attempt was made to call the method
com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;CLjava/lang/Object;)V
but it does not exist
An attempt was made to call the method
com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
but it does not exist
An attempt was made to call the method
com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor()Lcom/google/common/util/concurrent/ListeningExecutorService;
but it does not exist
Pure Java exceptions
java.lang.NoSuchMethodError:
com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;CLjava/lang/Object;)V
java.lang.NoSuchMethodError:
com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
java.lang.NoSuchMethodError:
com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor()Lcom/google/common/util/concurrent/ListeningExecutorService;
Suggested solutions
Method | Guava version |
com.google.common.base.Preconditions.checkArgument | 26.0-jre / 26.0-android |
com.google.common.base.Preconditions.checkState | 21.0 |
com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor | 18.0 / 19.0 |
Let me remind you that guava with maven is connected like this:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>version_here</version>
</dependency>
If suggested verions don’t fix the problem, you can try connecting the specified versions in order: 18.0 / 19.0 / 21.0 / 26.0-jre / 26.0-android.
If this does not help, it means that there are conflicting libraries in the project. In my case, Apache Curator library required version 18, and gRPC required version 26.0-android.
This is solved by updating the version of the library that uses the old version of guava. I updated the Apache Curator version and it worked.
This was figured out thanks to the fact that I built the maven dependency structure with this command:
mvn dependency:tree
If you need a settings file for maven to work, you can add the settings flag:
mvn dependency:tree -settings.xml
If you still have any questions, feel free to ask me in the comments under this article, or write me on promark33@gmail.com.