簡體   English   中英

Google雲端平台:無法從Container Engine訪問Pubsub

[英]Google Cloud Platform: cannot access Pubsub from Container Engine

我正在嘗試從運行在Google容器引擎中的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

這里有完整的堆棧跟蹤

我的Scala代碼完全符合快速入門指南:

val TopicName = "my-topic"
val pubsub = PubSubOptions.getDefaultInstance.getService
val topic = pubsub.getTopic(TopicName)
...
topic.publish(Message.of(json))

我想我可能會錯過一些重要的Kubernetes配置,所以非常感謝任何和所有的幫助。

我發現當sbt管理“com-google-cloud-pubsub”依賴時會出現這個問題。 我的工作是,我創建了一個maven項目,並構建了一個只有依賴項的jar。 然后我將jar添加到我的classpath和我的build.sbt中,我將“com-google-cloud-pubsub”注釋為“提供”。 我希望這適合你。

<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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM