Reputation: 12466
I'm trying to publish to an existing pubsub topic from a Scala application running in Google Container Engine (i.e. running in Kubernetes).
I have enabled (I think) the correct permissions for the underlying cluster:
However, when I try run my Scala application, I get the following error:
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
Full stack trace here.
My Scala code is pretty much right out of the quick start guide:
val TopicName = "my-topic"
val pubsub = PubSubOptions.getDefaultInstance.getService
val topic = pubsub.getTopic(TopicName)
...
topic.publish(Message.of(json))
I think I might be missing some vital Kubernetes configuration, so any and all help is very much appreciated.
Upvotes: 5
Views: 632
Reputation: 71
I've found that this problem happens when sbt manages the "com-google-cloud-pubsub" dependancy. My work around to this is, I created a maven project and built a jar with only that dependency. Then I added that jar to my classpath and in my build.sbt I annotated the "com-google-cloud-pubsub" as "provided". I hope this works for you.
<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>
Upvotes: 3