我正在尝试从在Google Container Engine中运行的Scala应用程序(即在Kubernetes中运行)发布到现有的pubsub主题。
我已经(我认为)为底层集群启用了正确的权限:

然而,当我尝试运行我的Scala应用程序时,我得到了以下错误:
2016-12-10T22:22:57.811982246Z Caused by:
com.google.cloud.pubsub.PubSubException: java.lang.IllegalStateException:
No NameResolverProviders found via ServiceLoader, including for DNS.
This is probably due to a broken build. If using ProGuard, check your configuration完整堆栈跟踪here。
我的Scala代码几乎完全脱离了快速入门指南:
val TopicName = "my-topic"
val pubsub = PubSubOptions.getDefaultInstance.getService
val topic = pubsub.getTopic(TopicName)
...
topic.publish(Message.of(json))我想我可能错过了一些重要的Kubernetes配置,所以任何帮助都是非常感谢的。
发布于 2016-12-16 00:56:25
我发现当sbt管理"com-google-cloud-pubsub“依赖关系时,就会出现这个问题。我对此所做的工作是,我创建了一个maven项目,并构建了一个仅具有该依赖项的jar。然后我将这个jar添加到我的类路径中,并在我的build.sbt中将"com-google-cloud-pubsub“注释为"provided”。我希望这对你有用。
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>0.8.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>https://stackoverflow.com/questions/41081055
复制相似问题