AppEngine 上的 PubSub Java-API 使用受限的 SelectorProvider
PubSub Java-API on AppEngine uses restricted SelectorProvider
尝试在我的 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 冲突。我怎样才能让它工作?
罗伯特,感谢您报告此事。解决问题。在此期间,请具体使用Google API Client Libraries for Java. Here's a link to the Pub/Sub client。
尝试在我的 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 冲突。我怎样才能让它工作?
罗伯特,感谢您报告此事。解决问题。在此期间,请具体使用Google API Client Libraries for Java. Here's a link to the Pub/Sub client。