简体   繁体   中英

Need help on NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor; in IntelliJ

There was a few other issues as this one but most of them were for android and I am currently working in IntelliJ with Java Gradle project.

My project is Gradle Java project in IntelliJ and I'm using Cloud Firestore as database. I am trying to make a .jar file so I can run the application, but it throws an exception.

I am probably doing something wrong when I when I create the .jar file because when I run the application in IntelliJ it works fine. The problem comes when I run the .jar file. The exception is as follows:

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
at io.grpc.internal.ClientCallImpl.<init>(ClientCallImpl.java:96)
at io.grpc.internal.ManagedChannelImpl$RealChannel.newCall(ManagedChannelImpl.java:662)
at io.grpc.internal.CensusTracingModule$TracingClientInterceptor.interceptCall(CensusTracingModule.java:382)
at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:104)
at io.grpc.internal.CensusStatsModule$StatsClientInterceptor.interceptCall(CensusStatsModule.java:675)
at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:104)
at com.google.api.gax.grpc.GrpcHeaderInterceptor.interceptCall(GrpcHeaderInterceptor.java:81)
at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:104)
at com.google.api.gax.grpc.GrpcMetadataHandlerInterceptor.interceptCall(GrpcMetadataHandlerInterceptor.java:55)
at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:104)
at io.grpc.internal.ManagedChannelImpl.newCall(ManagedChannelImpl.java:636)
at com.google.api.gax.grpc.GrpcClientCalls.newCall(GrpcClientCalls.java:66)
at com.google.api.gax.grpc.GrpcDirectServerStreamingCallable.call(GrpcDirectServerStreamingCallable.java:65)
at com.google.api.gax.grpc.GrpcExceptionServerStreamingCallable.call(GrpcExceptionServerStreamingCallable.java:62)
at com.google.api.gax.rpc.WatchdogServerStreamingCallable.call(WatchdogServerStreamingCallable.java:69)
at com.google.api.gax.rpc.ServerStreamingCallable$1.call(ServerStreamingCallable.java:220)
at com.google.api.gax.rpc.ServerStreamingCallable$1.call(ServerStreamingCallable.java:220)
at com.google.api.gax.rpc.ServerStreamingCallable.serverStreamingCall(ServerStreamingCallable.java:166)
at com.google.api.gax.rpc.ServerStreamingCallable.serverStreamingCall(ServerStreamingCallable.java:178)
at com.google.cloud.firestore.FirestoreImpl.streamRequest(FirestoreImpl.java:339)
at com.google.cloud.firestore.Query.stream(Query.java:955)
at com.google.cloud.firestore.Query.get(Query.java:995)
at com.google.cloud.firestore.Query.get(Query.java:965)
at main.main(main.java:39)

Line 39 in main.java is:

ApiFuture<QuerySnapshot> query = db.collection("collectionName").get();

I read that there is some version problem with Guava but I can't exclude the dependency in my build.gradle. I tried everything that I found but nothing worked.

Again, the project works fine when I run the main method in IntelliJ but when I run the .jar it throws the exception.

I will appreciate if I can receive some tips on how to create the .jar file or if there is any useful info on the Guava and how to fix the dependency.

Maybe you are using an old version of Guava. com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor has been introduced since Guava 18.0.

 * @since 18.0
 */
public static Executor directExecutor() {
  return DirectExecutor.INSTANCE;
}

See also: https://github.com/google/guava/commit/495f60836c95faa28955a1183a92b0ecd3b50365#diff-7a493427c77df959295f1d55574dbd50

Please check your dependencies of Guava in build.gradle and try upgrading it. If you are not using an old version, please click CTRL + N on IntelliJ and then enter com.google.common.util.concurrent.MoreExecutors to find the Guava jar which you are using.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM