1

Trying to use PubSub in my AppEngine I have added the following

<dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-pubsub</artifactId>
    <version>0.6.0</version>
</dependency>

When I try to get my PubSub instance

PubSub pubsub = PubSubOptions.getDefaultInstance().getService();

I receive this exception:

java.lang.NoClassDefFoundError: java.nio.channels.spi.SelectorProvider is a restricted class. Please see the Google App Engine developer's guide for more details.
at com.google.apphosting.runtime.security.shared.stub.java.nio.channels.spi.SelectorProvider.<clinit>(SelectorProvider.java)
at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:59)
at io.grpc.netty.Utils$DefaultEventLoopGroupResource.create(Utils.java:187)
at io.grpc.netty.Utils$DefaultEventLoopGroupResource.create(Utils.java:171)
at io.grpc.internal.SharedResourceHolder.getInternal(SharedResourceHolder.java:124)
at io.grpc.internal.SharedResourceHolder.get(SharedResourceHolder.java:94)
at io.grpc.netty.NettyChannelBuilder$NettyTransportFactory.<init>(NettyChannelBuilder.java:311)
at io.grpc.netty.NettyChannelBuilder$NettyTransportFactory.<init>(NettyChannelBuilder.java:280)
at io.grpc.netty.NettyChannelBuilder.buildTransportFactory(NettyChannelBuilder.java:230)
at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:239)
at com.google.api.gax.grpc.InstantiatingChannelProvider.createChannel(InstantiatingChannelProvider.java:120)
at com.google.api.gax.grpc.InstantiatingChannelProvider.getChannel(InstantiatingChannelProvider.java:107)
at com.google.api.gax.grpc.ProviderManager.getChannel(ProviderManager.java:107)
at com.google.api.gax.grpc.ChannelAndExecutor.create(ChannelAndExecutor.java:68)
at com.google.api.gax.grpc.ServiceApiSettings.getChannelAndExecutor(ServiceApiSettings.java:82)
at com.google.cloud.pubsub.spi.v1.PublisherApi.<init>(PublisherApi.java:203)
at com.google.cloud.pubsub.spi.v1.PublisherApi.create(PublisherApi.java:194)
at com.google.cloud.pubsub.spi.DefaultPubSubRpc.<init>(DefaultPubSubRpc.java:168)
at com.google.cloud.pubsub.PubSubOptions$DefaultPubSubRpcFactory.create(PubSubOptions.java:69)
at com.google.cloud.pubsub.PubSubOptions$DefaultPubSubRpcFactory.create(PubSubOptions.java:63)
at com.google.cloud.ServiceOptions.getRpc(ServiceOptions.java:478)
at com.google.cloud.pubsub.PubSubImpl.<init>(PubSubImpl.java:115)
at com.google.cloud.pubsub.PubSubOptions$DefaultPubSubFactory.create(PubSubOptions.java:44)
at com.google.cloud.pubsub.PubSubOptions$DefaultPubSubFactory.create(PubSubOptions.java:39)
at com.google.cloud.ServiceOptions.getService(ServiceOptions.java:465)

I understand that GAE doesn't allow the java.nio code, but I don't understand how Google can provide us with a PubSub API library that doesn't run on their own system.

Am I missing something? Some JAR-mismatch? I couldn't find any suspicious JAR conflits. How can I get this to work?

Robert Lill
  • 119
  • 1
  • 11

1 Answers1

0

Robert, Thank you for reporting this. Working the problem. In the meantime, please use the Google API Client Libraries for Java. Here's a link to the Pub/Sub client, specifically.

Kir Titievsky
  • 351
  • 2
  • 4
  • Yes, this works for me, thank you! As a matter of fact I was already using this library before I tried to move the the new one. – Robert Lill Nov 23 '16 at 15:05
  • Is this issue reported somewhere, so we can track and get notification when the newer PubSub library can be used in AE? – Ivan Balashov Jan 19 '17 at 12:19