在新的App Engine標準Java 8環境中,嘗試發佈到PubSub主題時出現以下錯誤:
io.grpc.internal.ChannelExecutor drain: Runnable threw exception in ChannelExecutor (ChannelExecutor.java:89)
java.lang.NullPointerException
at com.google.apphosting.runtime.ApiProxyImpl$CurrentRequestThreadFactory.newThread(ApiProxyImpl.java:1267)
at com.google.common.util.concurrent.ThreadFactoryBuilder$1.newThread(ThreadFactoryBuilder.java:162)
at java.util.concurrent.ThreadPoolExecutor$Worker.<init>(ThreadPoolExecutor.java:612)
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:925)
at java.util.concurrent.ThreadPoolExecutor.ensurePrestart(ThreadPoolExecutor.java:1587)
at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:336)
at java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:555)
at io.grpc.internal.ManagedChannelImpl.rescheduleIdleTimer(ManagedChannelImpl.java:334)
at io.grpc.internal.ManagedChannelImpl.exitIdleMode(ManagedChannelImpl.java:299)
at io.grpc.internal.ManagedChannelImpl$4$1.run(ManagedChannelImpl.java:357)
at io.grpc.internal.ChannelExecutor.drain(ChannelExecutor.java:87)
at io.grpc.internal.ManagedChannelImpl$4.get(ManagedChannelImpl.java:359)
at io.grpc.internal.ClientCallImpl.start(ClientCallImpl.java:218)
at io.grpc.ForwardingClientCall.start(ForwardingClientCall.java:47)
at com.google.api.gax.grpc.HeaderInterceptor$1.start(HeaderInterceptor.java:62)
at io.grpc.stub.ClientCalls.startCall(ClientCalls.java:276)
at io.grpc.stub.ClientCalls.asyncUnaryRequestCall(ClientCalls.java:252)
at io.grpc.stub.ClientCalls.futureUnaryCall(ClientCalls.java:186)
at com.google.pubsub.v1.PublisherGrpc$PublisherFutureStub.publish(PublisherGrpc.java:460)
at com.google.cloud.pubsub.v1.Publisher.publishOutstandingBatch(Publisher.java:329)
at com.google.cloud.pubsub.v1.Publisher.publishAllOutstanding(Publisher.java:304)
at com.google.cloud.pubsub.v1.Publisher.access$500(Publisher.java:79)
at com.google.cloud.pubsub.v1.Publisher$5.run(Publisher.java:283)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:295)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
相關的問題是這裏多一點信息:https://github.com/GoogleCloudPlatform/google-cloud-java/issues/2275
這是一個搖籃項目具有以下依存關係:
dependencies {
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
providedCompile 'com.google.appengine:appengine:+'
testCompile 'org.eclipse.jetty:jetty-server:9.+'
testCompile 'org.eclipse.jetty:jetty-servlet:9.+'
compile group: 'com.google.guava', name: 'guava', version: '19.+'
compile group: 'com.google.inject', name: 'guice', version: '4.+'
compile 'com.google.appengine:appengine-api-1.0-sdk:1.+'
compile 'com.google.cloud:google-cloud-storage:1.2+'
compile group: 'com.google.cloud', name: 'google-cloud-pubsub', version: '0.20+'
compile ('com.google.cloud:google-cloud-datastore:1.2+')
compile('com.google.apis:google-api-services-cloudkms:v1-rev15-1.22.0') {
exclude(group: 'com.google.guava', module: 'guava-jdk5')
}
compile(group: 'com.google.api-client', name: 'google-api-client', version: '1.+') {
exclude(group: 'com.google.guava', module: 'guava-jdk5')
}
compile(group: 'com.google.api-client', name: 'google-api-client-appengine', version: '1.+') {
exclude(group: 'com.google.guava', module: 'guava-jdk5')
}
}
我通過將war文件傳遞到appcfg.sh來部署,而不是使用App Engine Gradle插件。我的Java 8 靈活的環境中使用較舊的PubSub庫(0.11系列),但是由於使用較新的PubSub庫(0.20系列)切換到Java 8標準環境,我每次都會遇到此錯誤。
其他唯一的參考這個錯誤我已經看到了在這個谷歌網上論壇討論:https://groups.google.com/d/msg/google-appengine/2UTg4Eqskyk/PbqYEK3GAAAJ
更新1:
嘗試真正可怕的工作後,在周圍,谷歌組線程以上建議( https://gist.github.com/cmaan/7752e3c4fd0b1ba90a745cb6db232206)NPE已停止發生。但是,現在有一個新的問題:
Caused by: io.grpc.StatusRuntimeException: UNAUTHENTICATED
at io.grpc.Status.asRuntimeException(Status.java:543) ~[grpc-core-1.4.0.jar:1.4.0]
at io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:442) ~[grpc-stub-1.4.0.jar:1.4.0]
at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:426) ~[grpc-core-1.4.0.jar:1.4.0]
at io.grpc.internal.ClientCallImpl.access$100(ClientCallImpl.java:76) ~[grpc-core-1.4.0.jar:1.4.0]
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:512) ~[grpc-core-1.4.0.jar:1.4.0]
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$700(ClientCallImpl.java:429) ~[grpc-core-1.4.0.jar:1.4.0]
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:544) ~[grpc-core-1.4.0.jar:1.4.0]
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:52) ~[grpc-core-1.4.0.jar:1.4.0]
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:117) ~[grpc-core-1.4.0.jar:1.4.0]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_112-google-v7]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_112-google-v7]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[na:1.8.0_112-google-v7]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:295) ~[na:1.8.0_112-google-v7]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_112-google-v7]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_112-google-v7]
... 1 common frames omitted
Caused by: java.io.IOException: Could not get the access token.
at com.google.auth.oauth2.AppEngineCredentials.refreshAccessToken(AppEngineCredentials.java:136) ~[google-auth-library-oauth2-http-0.7.0.jar:na]
at com.google.auth.oauth2.OAuth2Credentials.refresh(OAuth2Credentials.java:149) ~[google-auth-library-oauth2-http-0.7.0.jar:na]
at com.google.auth.oauth2.OAuth2Credentials.getRequestMetadata(OAuth2Credentials.java:135) ~[google-auth-library-oauth2-http-0.7.0.jar:na]
at io.grpc.auth.GoogleAuthLibraryCallCredentials$1.run(GoogleAuthLibraryCallCredentials.java:110) ~[grpc-auth-1.4.0.jar:1.4.0]
... 7 common frames omitted
Caused by: java.lang.reflect.InvocationTargetException: null
at sun.reflect.GeneratedMethodAccessor60.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_112-google-v7]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_112-google-v7]
at com.google.auth.oauth2.AppEngineCredentials.refreshAccessToken(AppEngineCredentials.java:131) ~[google-auth-library-oauth2-http-0.7.0.jar:na]
... 10 common frames omitted
Caused by: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call memcache.Get in a thread that is neither the original request thread nor a thread created by ThreadManager
at com.google.apphosting.api.ApiProxy$CallNotFoundException.foreignThread(ApiProxy.java:844) ~[runtime-shared.jar:na]
at com.google.apphosting.api.ApiProxy$1.get(ApiProxy.java:183) ~[runtime-shared.jar:na]
at com.google.apphosting.api.ApiProxy$1.get(ApiProxy.java:180) ~[runtime-shared.jar:na]
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:93) ~[appengine-api.jar:na]
at com.google.appengine.api.memcache.MemcacheServiceImpl.quietGet(MemcacheServiceImpl.java:28) ~[appengine-api.jar:na]
at com.google.appengine.api.memcache.MemcacheServiceImpl.get(MemcacheServiceImpl.java:51) ~[appengine-api.jar:na]
at com.google.appengine.api.appidentity.AppIdentityServiceImpl.getAccessToken(AppIdentityServiceImpl.java:300) ~[appengine-api.jar:na]
... 14 common frames omitted