bazel运行在CensusStatsModule处给出java.lang.NoSuchFieldError

时间:2019-02-06 06:44:21

标签: java bazel grpc-java

我正在使用protobuf玩榛子和grpc。我已经按照在线指南和教程创建了一个简单的问候应用程序。使用mvn exec:java,可以使用我的IDE正常运行。但是,当我尝试运行由bazel build命令生成的二进制文件时,在运行时会得到以下信息

bazel-bin/greet_client
2019-02-05 22:27:49 INFO edu.jyo.app.gui.GreeterClient main Launching JavaFX client
2019-02-05 22:27:55 INFO edu.jyo.app.gui.GreeterClient$1 handle Sending message with text John
2019-02-05 22:27:55 INFO edu.jyo.app.client.GreeterServiceClient sayHello Invoking say hello
2019-02-05 22:27:55 WARNING io.grpc.stub.ClientCalls$ThreadlessExecutor waitAndDrain Runnable threw exception
java.lang.NoSuchFieldError: GRPC_CLIENT_SENT_MESSAGES_PER_METHOD
    at io.grpc.internal.CensusStatsModule$ClientTracer.outboundMessage(CensusStatsModule.java:311)
    at io.grpc.internal.StatsTraceContext.outboundMessage(StatsTraceContext.java:172)
    at io.grpc.internal.MessageFramer.writePayload(MessageFramer.java:131)
    at io.grpc.internal.AbstractStream.writeMessage(AbstractStream.java:53)
    at io.grpc.internal.ForwardingClientStream.writeMessage(ForwardingClientStream.java:37)
    at io.grpc.internal.DelayedStream$6.run(DelayedStream.java:229)
    at io.grpc.internal.DelayedStream.drainPendingCalls(DelayedStream.java:143)
    at io.grpc.internal.DelayedStream.setStream(DelayedStream.java:112)
    at io.grpc.internal.DelayedClientTransport$PendingStream.createRealStream(DelayedClientTransport.java:365)
    at io.grpc.internal.DelayedClientTransport$PendingStream.access$300(DelayedClientTransport.java:348)
    at io.grpc.internal.DelayedClientTransport$5.run(DelayedClientTransport.java:307)
    at io.grpc.stub.ClientCalls$ThreadlessExecutor.waitAndDrain(ClientCalls.java:645)
    at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:130)
    at edu.jyo.greet.service.protos.GreeterGrpc$GreeterBlockingStub.sayHello(GreeterGrpc.java:166)
    at edu.jyo.app.client.GreeterServiceClient.sayHello(GreeterServiceClient.java:37)
    at edu.jyo.app.gui.GreeterClient$1.handle(GreeterClient.java:38)
    at edu.jyo.app.gui.GreeterClient$1.handle(GreeterClient.java:33)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)

stacktrace似乎指向opencensus相关的jar。

我检查的第一件事是我是否具有不同版本的依赖关系,并且在maven pom.xml和为bazel生成的依赖关系之间似乎没有什么区别。

当我将grpc的版本从1.18.0降级到1.17.1时,它没有问题。

我对bazel的依赖性

#dependencies.yml
dependencies:
  io.grpc:
    grpc:
      modules: ["protobuf", "stub", "netty-shaded"]
      version: "1.18.0"
      lang: java

我的pom.xml

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <grpc.version>1.18.0</grpc.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-netty-shaded</artifactId>
            <version>${grpc.version}</version>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-protobuf</artifactId>
            <version>${grpc.version}</version>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-stub</artifactId>
            <version>${grpc.version}</version>
        </dependency>
    </dependencies>

完整的源代码以及生成的依赖关系在我的github存储库中-https://github.com/jyothri/grpc-chat

0 个答案:

没有答案