Google Cloud Platform: Unable to access Pubsub from container

I am trying to publish an existing pubsub section from a Scala application running on the Google Container Engine (i.e. it works on Kubernetes).

I have included (I think) the correct permissions for the base cluster:

permissions

However, when I try to start 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 very similar to a quick start guide:

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

I think that maybe I am missing some important Kubernetes configuration, so any help is greatly appreciated.

+5
source share
1 answer

I found that this problem occurs when sbt manages the dependency "com-google-cloud-pubsub". My work on this is that I created a maven project and built a jar with only this dependency. Then I added that jar is for my class path, and in my build.sbt file I annotated "com-google-cloud-pubsub" as "provided". 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> 
+3
source

Source: https://habr.com/ru/post/1261096/


All Articles