I've been grappling all day with java.lang.NoSuchMethodError issues, presumably due to Guava conflicts and some strange interaction with maven. I've also tried with different version of grpc-* and the protoc plugin, to no avail.
Relevant parts of my pom.xml:
> <dependency>
> <groupId>io.grpc</groupId>
> <artifactId>grpc-netty</artifactId>
> <version>1.0.3</version>
> </dependency>
> <dependency>
> <groupId>io.grpc</groupId>
> <artifactId>grpc-protobuf</artifactId>
> <version>1.0.3</version>
> </dependency>
> <dependency>
> <groupId>io.grpc</groupId>
> <artifactId>grpc-stub</artifactId>
> <version>1.0.3</version>
> </dependency>
> <plugins>
> <plugin>
> <groupId>org.xolstice.maven.plugins</groupId>
> <artifactId>protobuf-maven-plugin</artifactId>
> <version>0.5.0</version>
> <configuration>
> <protocArtifact>com.google.protobuf:protoc:3.0.2:exe:${os.detected.classifier}</protocArtifact>
> <pluginId>grpc-java</pluginId>
> <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.0.3:exe:${os.detected.classifier}</pluginArtifact>
> <checkStaleness>true</checkStaleness>
> </configuration>
> <executions>
> <execution>
> <goals>
> <goal>compile</goal>
> <goal>compile-custom</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> <plugin>
>
Here is also the relevant output of mvn dependency:tree -X:
[INFO] +- junit:junit:jar:4.12:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.checkerframework:checker-qual:jar:2.1.6:compile
[INFO] +- org.checkerframework:checker:jar:2.1.6:compile
[INFO] +- org.checkerframework:compiler:jar:2.1.6:compile
[INFO] +- org.checkerframework:jdk8:jar:2.1.6:compile
[INFO] +- io.grpc:grpc-netty:jar:1.0.3:compile
[INFO] | +- io.grpc:grpc-core:jar:1.0.3:compile (version selected from constraint [1.0.3,1.0.3])
[INFO] | | +- io.grpc:grpc-context:jar:1.0.3:compile
[INFO] | | \- com.google.code.findbugs:jsr305:jar:3.0.0:compile
[INFO] | +- io.netty:netty-handler-proxy:jar:4.1.6.Final:compile
[INFO] | | +- io.netty:netty-transport:jar:4.1.6.Final:compile
[INFO] | | | +- io.netty:netty-buffer:jar:4.1.6.Final:compile
[INFO] | | | | \- io.netty:netty-common:jar:4.1.6.Final:compile
[INFO] | | | \- io.netty:netty-resolver:jar:4.1.6.Final:compile
[INFO] | | +- io.netty:netty-codec-socks:jar:4.1.6.Final:compile
[INFO] | | | \- io.netty:netty-codec:jar:4.1.6.Final:compile
[INFO] | | \- io.netty:netty-codec-http:jar:4.1.6.Final:compile
[INFO] | \- io.netty:netty-codec-http2:jar:4.1.6.Final:compile (version selected from constraint [4.1.6.Final,4.1.6.Final])
[INFO] | \- io.netty:netty-handler:jar:4.1.6.Final:compile
[INFO] +- io.grpc:grpc-protobuf:jar:1.0.3:compile
[INFO] | +- com.google.guava:guava:jar:19.0:compile
[INFO] | +- com.google.protobuf:protobuf-java-util:jar:3.0.2:compile
[INFO] | | \- com.google.code.gson:gson:jar:2.3:compile
[INFO] | +- com.google.protobuf:protobuf-java:jar:3.0.2:compile
[INFO] | \- io.grpc:grpc-protobuf-lite:jar:1.0.3:compile
[INFO] \- io.grpc:grpc-stub:jar:1.0.3:compile
Please answer these questions before submitting your issue.
1.0.3 (also tried 1.1.2)
java -version)?java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
If possible, provide a recipe for reproducing the error.
(See above for pom.xml)
I then followed the HelloWorld example to build a client and a server. In a Junit test case, the client simply invokes the rpc via a blockingStub.
No errors.
With 1.0.3
java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
at io.grpc.internal.ClientCallImpl.<init>(ClientCallImpl.java:103)
at io.grpc.internal.ManagedChannelImpl$RealChannel.newCall(ManagedChannelImpl.java:556)
at io.grpc.internal.ManagedChannelImpl.newCall(ManagedChannelImpl.java:535)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:133)
With 1.1.2
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V
at io.grpc.ServiceDescriptor.validateMethodNames(ServiceDescriptor.java:129)
at io.grpc.ServiceDescriptor.<init>(ServiceDescriptor.java:83)
at io.grpc.ServiceDescriptor.<init>(ServiceDescriptor.java:78)
at io.grpc.ServiceDescriptor.<init>(ServiceDescriptor.java:66)
Those are Guava bugs. The second one comes from a mismatch between 20 and others, The first one I am not sure. MoreExecutors.directExecutor has been around since 18, so it seems like you are using a much older version.
Which Guava are you using? Perhaps being pulled in somewhere else?
$: mvn dependency:tree | grep -i guava
[INFO] | +- com.google.guava:guava:jar:19.0:compile
That said, it looks like protobuf-maven-plugin (0.5.0) does depend on Guava version 18.
Any suggestions on how I can debug this?
I found the culprit. It was the checker framework dependency, removing which fixed the issue.
Hi,
I'm having the same issue (1.1.2):
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V
at io.grpc.ServiceDescriptor.validateMethodNames(ServiceDescriptor.java:129)
at io.grpc.ServiceDescriptor.<init>(ServiceDescriptor.java:83)
at io.grpc.ServiceDescriptor.<init>(ServiceDescriptor.java:78)
at io.grpc.ServiceDescriptor.<init>(ServiceDescriptor.java:66)
I'm not sure to get how you sorted that out. Can you give a bit more details?
Best regards.
@MarcMagnin The problem is that you have an older version of guava somewhere on your classpath. Can you print out your deps? It should be something like ./gradlew my-project:dependencies.
Thanks for that quick reply @carl-mastrangelo !
That's right, guava 16, 16.0.1, 18 and 20:
+--- org.apache.cassandra:cassandra-all:3.0.10
| +--- org.xerial.snappy:snappy-java:1.1.1.7
| +--- net.jpountz.lz4:lz4:1.3.0
| +--- com.ning:compress-lzf:0.8.4
| +--- com.google.guava:guava:18.0 -> 20.0
| +--- commons-cli:commons-cli:1.1
| +--- commons-codec:commons-codec:1.2 -> 1.6
| +--- org.apache.commons:commons-lang3:3.1
| +--- org.apache.commons:commons-math3:3.2
| +--- com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4
| +--- org.antlr:antlr:3.5.2
| | +--- org.antlr:antlr-runtime:3.5.2
| | \--- org.antlr:ST4:4.0.8
| | \--- org.antlr:antlr-runtime:3.5.2
| +--- org.antlr:antlr-runtime:3.5.2
| +--- org.slf4j:slf4j-api:1.7.7 -> 1.7.22
| +--- org.slf4j:log4j-over-slf4j:1.7.7
| | \--- org.slf4j:slf4j-api:1.7.7 -> 1.7.22
| +--- org.slf4j:jcl-over-slf4j:1.7.7
| | \--- org.slf4j:slf4j-api:1.7.7 -> 1.7.22
| +--- org.codehaus.jackson:jackson-core-asl:1.9.2
| +--- org.codehaus.jackson:jackson-mapper-asl:1.9.2
| | \--- org.codehaus.jackson:jackson-core-asl:1.9.2
| +--- com.googlecode.json-simple:json-simple:1.1
| +--- com.boundary:high-scale-lib:1.0.6
| +--- org.yaml:snakeyaml:1.11 -> 1.12
| +--- org.mindrot:jbcrypt:0.3m
| +--- io.dropwizard.metrics:metrics-core:3.1.0 -> 3.1.2
| | \--- org.slf4j:slf4j-api:1.7.7 -> 1.7.22
| +--- io.dropwizard.metrics:metrics-jvm:3.1.0
| | +--- io.dropwizard.metrics:metrics-core:3.1.0 -> 3.1.2 (*)
| | \--- org.slf4j:slf4j-api:1.7.7 -> 1.7.22
| +--- com.addthis.metrics:reporter-config3:3.0.0
| | +--- com.addthis.metrics:reporter-config-base:3.0.0
| | | +--- org.slf4j:slf4j-api:1.7.7 -> 1.7.22
| | | +--- org.yaml:snakeyaml:1.12
| | | +--- org.hibernate:hibernate-validator:4.3.0.Final
| | | | +--- javax.validation:validation-api:1.0.0.GA
| | | | \--- org.jboss.logging:jboss-logging:3.1.0.CR2
| | | \--- org.apache.commons:commons-lang3:3.1
| | +--- io.dropwizard.metrics:metrics-core:3.1.0 -> 3.1.2 (*)
| | +--- org.slf4j:slf4j-api:1.7.7 -> 1.7.22
| | +--- org.yaml:snakeyaml:1.12
| | +--- org.hibernate:hibernate-validator:4.3.0.Final (*)
| | \--- org.apache.commons:commons-lang3:3.1
| +--- com.thinkaurelius.thrift:thrift-server:0.3.7
| | +--- com.lmax:disruptor:3.0.1
| | +--- org.apache.thrift:libthrift:0.9.1 -> 0.9.2
| | | +--- org.slf4j:slf4j-api:1.5.8 -> 1.7.22
| | | +--- org.apache.httpcomponents:httpclient:4.2.5
| | | | +--- org.apache.httpcomponents:httpcore:4.2.4
| | | | +--- commons-logging:commons-logging:1.1.1
| | | | \--- commons-codec:commons-codec:1.6
| | | \--- org.apache.httpcomponents:httpcore:4.2.4
| | +--- org.slf4j:slf4j-api:1.6.1 -> 1.7.22
| | \--- junit:junit:4.8.1
| +--- com.clearspring.analytics:stream:2.5.2
| | \--- it.unimi.dsi:fastutil:6.5.7
| +--- ch.qos.logback:logback-core:1.1.3
| +--- ch.qos.logback:logback-classic:1.1.3
| | +--- ch.qos.logback:logback-core:1.1.3
| | \--- org.slf4j:slf4j-api:1.7.7 -> 1.7.22
| +--- org.apache.thrift:libthrift:0.9.2 (*)
| +--- org.apache.cassandra:cassandra-thrift:3.0.10
| | +--- org.apache.commons:commons-lang3:3.1
| | +--- org.slf4j:slf4j-api:1.7.7 -> 1.7.22
| | +--- org.slf4j:log4j-over-slf4j:1.7.7 (*)
| | +--- org.slf4j:jcl-over-slf4j:1.7.7 (*)
| | \--- org.apache.thrift:libthrift:0.9.2 (*)
| +--- net.java.dev.jna:jna:4.0.0 -> 4.1.0
| +--- com.github.jbellis:jamm:0.3.0
| +--- io.netty:netty-all:4.0.23.Final
| +--- joda-time:joda-time:2.4
| +--- org.fusesource:sigar:1.6.4
| +--- org.eclipse.jdt.core.compiler:ecj:4.4.2
| \--- org.caffinitas.ohc:ohc-core:0.4.3
| +--- org.slf4j:slf4j-api:1.7.12 -> 1.7.22
| +--- com.google.guava:guava:16.0 -> 20.0
| \--- net.java.dev.jna:jna:4.1.0
+--- com.datastax.cassandra:cassandra-driver-core:3.1.3
| +--- io.netty:netty-handler:4.0.37.Final -> 4.1.8.Final
| | +--- io.netty:netty-buffer:4.1.8.Final
| | | \--- io.netty:netty-common:4.1.8.Final
| | +--- io.netty:netty-transport:4.1.8.Final
| | | +--- io.netty:netty-buffer:4.1.8.Final (*)
| | | \--- io.netty:netty-resolver:4.1.8.Final
| | | \--- io.netty:netty-common:4.1.8.Final
| | \--- io.netty:netty-codec:4.1.8.Final
| | \--- io.netty:netty-transport:4.1.8.Final (*)
| +--- com.google.guava:guava:16.0.1 -> 20.0
| +--- io.dropwizard.metrics:metrics-core:3.1.2 (*)
| +--- com.github.jnr:jnr-ffi:2.0.7
| | +--- com.github.jnr:jffi:1.2.10
| | +--- org.ow2.asm:asm:5.0.3
| | +--- org.ow2.asm:asm-commons:5.0.3
| | | \--- org.ow2.asm:asm-tree:5.0.3
| | | \--- org.ow2.asm:asm:5.0.3
| | +--- org.ow2.asm:asm-analysis:5.0.3
| | | \--- org.ow2.asm:asm-tree:5.0.3 (*)
| | +--- org.ow2.asm:asm-tree:5.0.3 (*)
| | +--- org.ow2.asm:asm-util:5.0.3
| | | \--- org.ow2.asm:asm-tree:5.0.3 (*)
| | \--- com.github.jnr:jnr-x86asm:1.0.2
| \--- com.github.jnr:jnr-posix:3.0.27
| +--- com.github.jnr:jnr-ffi:2.0.7 (*)
| \--- com.github.jnr:jnr-constants:0.9.0
+--- org.springframework:spring-instrument:4.3.6.RELEASE
+--- com.google.protobuf:protobuf-java:3.1.0
+--- io.grpc:grpc-stub:1.1.2
| \--- io.grpc:grpc-core:1.1.2
| +--- com.google.guava:guava:20.0
| +--- com.google.errorprone:error_prone_annotations:2.0.11
| +--- com.google.code.findbugs:jsr305:3.0.0
| +--- io.grpc:grpc-context:1.1.2
| \--- com.google.instrumentation:instrumentation-api:0.3.0
| \--- com.google.code.findbugs:jsr305:3.0.0
+--- io.grpc:grpc-netty:1.1.2
| +--- io.grpc:grpc-core:[1.1.2] -> 1.1.2 (*)
| +--- io.netty:netty-codec-http2:[4.1.8.Final] -> 4.1.8.Final
| | +--- io.netty:netty-codec-http:4.1.8.Final
| | | \--- io.netty:netty-codec:4.1.8.Final (*)
| | \--- io.netty:netty-handler:4.1.8.Final (*)
| \--- io.netty:netty-handler-proxy:4.1.8.Final
| +--- io.netty:netty-transport:4.1.8.Final (*)
| +--- io.netty:netty-codec-socks:4.1.8.Final
| | \--- io.netty:netty-codec:4.1.8.Final (*)
| \--- io.netty:netty-codec-http:4.1.8.Final (*)
+--- io.grpc:grpc-protobuf:1.1.2
| +--- io.grpc:grpc-core:1.1.2 (*)
| +--- com.google.protobuf:protobuf-java:3.1.0
| +--- com.google.guava:guava:20.0
| +--- com.google.protobuf:protobuf-java-util:3.1.0
| | +--- com.google.protobuf:protobuf-java:3.1.0
| | +--- com.google.guava:guava:18.0 -> 20.0
| | \--- com.google.code.gson:gson:2.7
| \--- io.grpc:grpc-protobuf-lite:1.1.2
| +--- io.grpc:grpc-core:1.1.2 (*)
| \--- com.google.guava:guava:20.0
+--- org.slf4j:slf4j-simple:1.7.22
| \--- org.slf4j:slf4j-api:1.7.22
+--- net.bytebuddy:byte-buddy-agent:1.6.7
+--- net.bytebuddy:byte-buddy:1.6.7
+--- io.netty:netty-codec-http2:4.1.8.Final (*)
+--- io.netty:netty-handler:4.1.8.Final (*)
+--- io.netty:netty-handler-proxy:4.1.8.Final (*)
\--- com.google.guava:guava:20.0
Right now I'm trying to build a "fatjar" using gradle shadow plugin (com.github.johnrengelman.shadow) but I got the same error so far. The following dependencies will be loaded up as an agent to an app with most of the previous dependencies:
+--- org.springframework:spring-instrument:4.3.6.RELEASE
+--- com.google.protobuf:protobuf-java:3.1.0
+--- io.grpc:grpc-stub:1.1.2
| \--- io.grpc:grpc-core:1.1.2
| +--- com.google.guava:guava:20.0
| +--- com.google.errorprone:error_prone_annotations:2.0.11
| +--- com.google.code.findbugs:jsr305:3.0.0
| +--- io.grpc:grpc-context:1.1.2
| \--- com.google.instrumentation:instrumentation-api:0.3.0
| \--- com.google.code.findbugs:jsr305:3.0.0
+--- io.grpc:grpc-netty:1.1.2
| +--- io.grpc:grpc-core:[1.1.2] -> 1.1.2 (*)
| +--- io.netty:netty-codec-http2:[4.1.8.Final] -> 4.1.8.Final
| | +--- io.netty:netty-codec-http:4.1.8.Final
| | | \--- io.netty:netty-codec:4.1.8.Final
| | | \--- io.netty:netty-transport:4.1.8.Final
| | | +--- io.netty:netty-buffer:4.1.8.Final
| | | | \--- io.netty:netty-common:4.1.8.Final
| | | \--- io.netty:netty-resolver:4.1.8.Final
| | | \--- io.netty:netty-common:4.1.8.Final
| | \--- io.netty:netty-handler:4.1.8.Final
| | +--- io.netty:netty-buffer:4.1.8.Final (*)
| | +--- io.netty:netty-transport:4.1.8.Final (*)
| | \--- io.netty:netty-codec:4.1.8.Final (*)
| \--- io.netty:netty-handler-proxy:4.1.8.Final
| +--- io.netty:netty-transport:4.1.8.Final (*)
| +--- io.netty:netty-codec-socks:4.1.8.Final
| | \--- io.netty:netty-codec:4.1.8.Final (*)
| \--- io.netty:netty-codec-http:4.1.8.Final (*)
+--- io.grpc:grpc-protobuf:1.1.2
| +--- io.grpc:grpc-core:1.1.2 (*)
| +--- com.google.protobuf:protobuf-java:3.1.0
| +--- com.google.guava:guava:20.0
| +--- com.google.protobuf:protobuf-java-util:3.1.0
| | +--- com.google.protobuf:protobuf-java:3.1.0
| | +--- com.google.guava:guava:18.0 -> 20.0
| | \--- com.google.code.gson:gson:2.7
| \--- io.grpc:grpc-protobuf-lite:1.1.2
| +--- io.grpc:grpc-core:1.1.2 (*)
| \--- com.google.guava:guava:20.0
+--- org.slf4j:slf4j-simple:1.7.22
| \--- org.slf4j:slf4j-api:1.7.22
+--- net.bytebuddy:byte-buddy-agent:1.6.7
+--- net.bytebuddy:byte-buddy:1.6.7
+--- io.netty:netty-codec-http2:4.1.8.Final (*)
+--- io.netty:netty-handler:4.1.8.Final (*)
+--- io.netty:netty-handler-proxy:4.1.8.Final (*)
+--- com.google.guava:guava:20.0
\--- junit:junit:4.11
\--- org.hamcrest:hamcrest-core:1.3
Any suggestion is welcome.
There is talk of backing off of Guava 20 for gRPC and just copying methods that Guava provides us in newer versions, but that won't help with the executors stuff. Sadly, it seems like shading is actually the answer here
Updating Guava version to guava-23.0.jar fixed for me.
Updated latest guava 23.2-jre. it fixed this for me. 馃憤
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>23.2-jre</version>
</dependency>
For me instead of Upgrading the Guava to latest ver, I had to exclude Guava JDK5 dependency in configurations to fix the error. Did something like below
configurations {
all*.exclude group: 'com.google.guava', module:'guava-jdk5'
}
Most helpful comment
For me instead of Upgrading the Guava to latest ver, I had to exclude Guava JDK5 dependency in configurations to fix the error. Did something like below