AppEngine上的PubSub Java-API使用受限制的SelectorProvider

时间:2016-11-22 12:13:38

标签: java google-app-engine google-cloud-pubsub

尝试在AppEngine中使用PubSub我添加了以下内容

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

当我尝试获取我的PubSub实例时

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

我收到此例外:

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)

我知道GAE不允许使用java.nio代码,但我不明白Google如何为我们提供不在自己的系统上运行的PubSub API库。

我错过了什么吗?一些JAR不匹配?我找不到任何可疑的JAR错误。我怎样才能让它发挥作用?

1 个答案:

答案 0 :(得分:0)

罗伯特,谢谢你报道这件事。解决问题。在此期间,请使用Google API Client Libraries for Java。这是Pub/Sub client的链接,具体而言。