【发布时间】:2017-03-08 19:38:15
【问题描述】:
所以,我下载了 Google Cloud Java samples 并尝试运行带有流式示例的 jar。为此,我通过在具有 jar-with-dependencies 描述符标签的标签末尾添加主类标签来修改 pom.xml。
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.examples.cloud.speech.StreamingRecognizeClient</mainClass>
</manifest>
</archive>
问题是我在尝试运行打包的 jar 时收到此错误,mvn compile 和 package 工作正常,但运行此命令失败。
我检查了 grpc 包,maxInboundMessageSize() 就在 NettyChannelBuilder 扩展的 AbstractManagedChannelImplBuilder 中。当我从 Intellij 运行该示例时,它运行良好。
java -jar grpc-sample-1.0-jar-with-dependencies.jar master
Exception in thread "main" java.lang.NoSuchMethodError: io.grpc.netty.NettyChannelBuilder.maxInboundMessageSize()I
at io.grpc.netty.NettyChannelBuilder.buildTransportFactory(NettyChannelBuilder.java:263)
at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:239)
at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:69)
at com.examples.cloud.speech.StreamingRecognizeClient.createChannel(StreamingRecognizeClient.java:109)
at com.examples.cloud.speech.StreamingRecognizeClient.main(StreamingRecognizeClient.java:282)
当我保持 pom.xml 不变而是运行时会发生同样的事情:
java -cp target/grpc-sample-1.0-jar-with-dependencies.jar com.examples.cloud.speech.StreamingRecognizeClient
我还想知道为什么我的其他打包选项使用 Maven,我以前从未使用过它,而且我很确定我搞砸了。
谢谢
【问题讨论】:
-
看起来使用了一些错误版本的 netty grpc 依赖。可能是worth reporting a bug。
-
是的,它看起来确实像一个错误,我希望也许我做错了什么,并且会有一个修复。
-
我已将所有 grpc 工件从 1.1.2 回滚到 1.0.3。现在应该可以工作了——抱歉这个问题。 (机器人应该在更新之前测试这些东西)
-
@LesVogel-GoogleDevRel pom 仍在尝试使用 1.1.2 并且问题仍然存在。请合并更改。
-
叹息 - 有时更新的机器人比它应该的更具侵略性。回滚到 1.0.3
标签: java maven intellij-idea google-cloud-platform grpc