У меня есть служба gRP C, которую я запускаю, все хорошо, без ошибок. Тем не менее, когда я пытаюсь использовать grpcui
(./grpcui -plaintext localhost:9900
), который будет читать и для службы, я получаю следующее:
Exception in thread "grpc-default-executor-0" java.lang.NoSuchMethodError: com.google.protobuf.Descriptors$FileDescriptor.internalBuildGeneratedFileFrom([Ljava/lang/String;[Lcom/google/protobuf/Descriptors$FileDescriptor;)Lcom/google/protobuf/Descriptors$FileDescriptor;
at io.grpc.reflection.v1alpha.ServerReflectionProto.<clinit>(ServerReflectionProto.java:103)
at io.grpc.reflection.v1alpha.ServerReflectionGrpc$ServerReflectionBaseDescriptorSupplier.getFileDescriptor(ServerReflectionGrpc.java:234)
at io.grpc.protobuf.services.ProtoReflectionService$FileDescriptorIndex.<init>(ProtoReflectionService.java:418)
at io.grpc.protobuf.services.ProtoReflectionService$ServerReflectionIndex.<init>(ProtoReflectionService.java:339)
at io.grpc.protobuf.services.ProtoReflectionService.updateIndexIfNecessary(ProtoReflectionService.java:97)
at io.grpc.protobuf.services.ProtoReflectionService.serverReflectionInfo(ProtoReflectionService.java:136)
at io.grpc.reflection.v1alpha.ServerReflectionGrpc$MethodHandlers.invoke(ServerReflectionGrpc.java:220)
at io.grpc.stub.ServerCalls$StreamingServerCallHandler.startCall(ServerCalls.java:224)
at io.grpc.internal.ServerImpl$ServerTransportListenerImpl.startWrappedCall(ServerImpl.java:648)
at io.grpc.internal.ServerImpl$ServerTransportListenerImpl.startCall(ServerImpl.java:626)
at io.grpc.internal.ServerImpl$ServerTransportListenerImpl.access$1900(ServerImpl.java:417)
at io.grpc.internal.ServerImpl$ServerTransportListenerImpl$1StreamCreated.runInternal(ServerImpl.java:556)
at io.grpc.internal.ServerImpl$ServerTransportListenerImpl$1StreamCreated.runInContext(ServerImpl.java:531)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
и
Exception in thread "grpc-default-executor-1" java.lang.NoClassDefFoundError: Could not initialize class io.grpc.reflection.v1alpha.ServerReflectionProto
at io.grpc.reflection.v1alpha.ServerReflectionGrpc$ServerReflectionBaseDescriptorSupplier.getFileDescriptor(ServerReflectionGrpc.java:234)
at io.grpc.protobuf.services.ProtoReflectionService$FileDescriptorIndex.<init>(ProtoReflectionService.java:418)
at io.grpc.protobuf.services.ProtoReflectionService$ServerReflectionIndex.<init>(ProtoReflectionService.java:339)
at io.grpc.protobuf.services.ProtoReflectionService.updateIndexIfNecessary(ProtoReflectionService.java:97)
at io.grpc.protobuf.services.ProtoReflectionService.serverReflectionInfo(ProtoReflectionService.java:136)
at io.grpc.reflection.v1alpha.ServerReflectionGrpc$MethodHandlers.invoke(ServerReflectionGrpc.java:220)
at io.grpc.stub.ServerCalls$StreamingServerCallHandler.startCall(ServerCalls.java:224)
at io.grpc.internal.ServerImpl$ServerTransportListenerImpl.startWrappedCall(ServerImpl.java:648)
at io.grpc.internal.ServerImpl$ServerTransportListenerImpl.startCall(ServerImpl.java:626)
at io.grpc.internal.ServerImpl$ServerTransportListenerImpl.access$1900(ServerImpl.java:417)
at io.grpc.internal.ServerImpl$ServerTransportListenerImpl$1StreamCreated.runInternal(ServerImpl.java:556)
at io.grpc.internal.ServerImpl$ServerTransportListenerImpl$1StreamCreated.runInContext(ServerImpl.java:531)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Мой сервис:
public class OneSideInitiated extends SideGrpc.SideImplBase {
@Override
public void requestStart(RemoteStartRequest request,
StreamObserver<RemoteStartResponse> responseObserver) {
RemoteStartResponse response = RemoteStartResponse.newBuilder().build();
responseObserver.onNext(response);
responseObserver.onCompleted();
}
}
Класс, запускающий службу:
import io.grpc.Server;
import io.grpc.ServerBuilder;
import io.grpc.protobuf.services.ProtoReflectionService;
public class StuffServer {
private Server server;
public StuffServer(int port) {
this.server = ServerBuilder.forPort(port)
.addService(ProtoReflectionService.newInstance())
.addService(new OneSideInitiated())
.build();
}
public void start() throws IOException {
server.start();
}
public void stop() throws InterruptedException {...}
public static void main(String[] args) throws Exception {
CccpServer cccpServer = new StuffServer(9900);
cccpServer.start();
cccpServer.blockUntilShutdown();
}
private void blockUntilShutdown() throws InterruptedException {...}
}
Мои зависимости Maven:
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.26.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
<version>1.26.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>1.26.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-services</artifactId>
<version>1.26.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>23.6.1-jre</version>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>
<version>0.1.9</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-testing</artifactId>
<version>1.26.0</version>
<scope>testing</scope>
</dependency>
Пробовали различные комбинации guava
и io.grpc
версии, не имеет никакого значения. У кого-нибудь есть идеи по этому поводу?