Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoSuchMethodError: com.google.common.base.Preconditions.checkArgument

I keep getting this error:

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;I)V
    at com.google.cloud.pubsub.v1.Subscriber.<init>(Subscriber.java:138)
    at com.google.cloud.pubsub.v1.Subscriber.<init>(Subscriber.java:93)
    at com.google.cloud.pubsub.v1.Subscriber$Builder.build(Subscriber.java:623)
    at com.vanitysoft.payit.domain.dao.SubApp.main(SubApp.java:31)

i have this in my pom.xml

    <dependency>
        <groupId>com.google.cloud</groupId>
        <artifactId>google-cloud-pubsub</artifactId>
        <version>0.32.0-beta</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>23.5-jre</version>
    </dependency>

can somone share there pom settings for the google pub/sub? I am using an standalone app.

like image 862
Jeryl Cook Avatar asked Feb 11 '26 04:02

Jeryl Cook


1 Answers

com.google.cloud:google-cloud-pubsub:0.32.0-beta transitively requires com.google.guava:guava:jar:20.0 yet you have overridden Guava with a newer version. You can see it by running mvn dependency:tree:

\- com.google.cloud:google-cloud-pubsub:jar:0.32.0-beta:compile
   +- io.netty:netty-tcnative-boringssl-static:jar:2.0.6.Final:compile
   +- com.google.cloud:google-cloud-core:jar:1.14.0:compile
   |  +- com.google.guava:guava:jar:20.0:compile
   |  +- joda-time:joda-time:jar:2.9.2:compile
   |  +- org.json:json:jar:20160810:compile
   |  +- com.google.http-client:google-http-client:jar:1.23.0:compile
   |  |  \- org.apache.httpcomponents:httpclient:jar:4.0.1:compile
   |  |     +- org.apache.httpcomponents:httpcore:jar:4.0.1:compile
   |  |     +- commons-logging:commons-logging:jar:1.1.1:compile
   |  |     \- commons-codec:commons-codec:jar:1.3:compile
   |  +- com.google.code.findbugs:jsr305:jar:3.0.0:compile
   |  +- com.google.api:api-common:jar:1.2.0:compile
   |  +- com.google.api:gax:jar:1.15.0:compile
   |  |  +- com.google.auto.value:auto-value:jar:1.2:compile
   |  |  +- org.threeten:threetenbp:jar:1.3.3:compile
   |  |  \- com.google.auth:google-auth-library-oauth2-http:jar:0.9.0:compile
   |  |     \- com.google.http-client:google-http-client-jackson2:jar:1.19.0:compile
   |  |        \- com.fasterxml.jackson.core:jackson-core:jar:2.1.3:compile
   |  +- com.google.protobuf:protobuf-java-util:jar:3.4.0:compile
   |  |  \- com.google.code.gson:gson:jar:2.7:compile
   |  +- com.google.api.grpc:proto-google-common-protos:jar:1.0.2:compile
   |  \- com.google.api.grpc:proto-google-iam-v1:jar:0.1.26:compile
   +- com.google.cloud:google-cloud-core-grpc:jar:1.14.0:compile
   |  +- com.google.auth:google-auth-library-credentials:jar:0.9.0:compile
   |  +- com.google.protobuf:protobuf-java:jar:3.4.0:compile
   |  +- io.grpc:grpc-protobuf:jar:1.7.0:compile
   |  |  \- io.grpc:grpc-protobuf-lite:jar:1.7.0:compile
   |  +- io.grpc:grpc-context:jar:1.7.0:compile
   |  \- com.google.api:gax-grpc:jar:1.15.0:compile
   +- com.google.api.grpc:proto-google-cloud-pubsub-v1:jar:0.1.26:compile
   +- com.google.api.grpc:grpc-google-cloud-pubsub-v1:jar:0.1.26:compile
   +- io.grpc:grpc-netty:jar:1.7.0:compile
   |  +- io.grpc:grpc-core:jar:1.7.0:compile (version selected from constraint [1.7.0,1.7.0])
   |  |  +- com.google.errorprone:error_prone_annotations:jar:2.0.19:compile
   |  |  +- com.google.instrumentation:instrumentation-api:jar:0.4.3:compile
   |  |  \- io.opencensus:opencensus-api:jar:0.6.0:compile
   |  +- io.netty:netty-codec-http2:jar:4.1.16.Final:compile (version selected from constraint [4.1.16.Final,4.1.16.Final])
   |  |  +- io.netty:netty-codec-http:jar:4.1.16.Final:compile
   |  |  |  \- io.netty:netty-codec:jar:4.1.16.Final:compile
   |  |  \- io.netty:netty-handler:jar:4.1.16.Final:compile
   |  |     \- io.netty:netty-buffer:jar:4.1.16.Final:compile
   |  |        \- io.netty:netty-common:jar:4.1.16.Final:compile
   |  \- io.netty:netty-handler-proxy:jar:4.1.16.Final:compile
   |     +- io.netty:netty-transport:jar:4.1.16.Final:compile
   |     |  \- io.netty:netty-resolver:jar:4.1.16.Final:compile
   |     \- io.netty:netty-codec-socks:jar:4.1.16.Final:compile
   +- io.grpc:grpc-stub:jar:1.7.0:compile
   \- io.grpc:grpc-auth:jar:1.7.0:compile

Based on your pom.xml snippet you should remove your version of Guava unless some other libraries in your project need this newer version.

like image 59
Karol Dowbecki Avatar answered Feb 14 '26 12:02

Karol Dowbecki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!