javagoogle-app-enginegoogle-cloud-pubsubclient-library

Google Pub/Sub in GAE


Using pub/sub java client libraries in GAE application doesn't work, I get an exception

Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "shutdownHooks")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
at java.security.AccessController.checkPermission(AccessController.java:559)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:442)
at java.lang.Runtime.addShutdownHook(Runtime.java:209)
at com.google.common.util.concurrent.MoreExecutors$Application.addShutdownHook(MoreExecutors.java:223)
at com.google.common.util.concurrent.MoreExecutors$Application.addDelayedShutdownHook(MoreExecutors.java:195)
at com.google.common.util.concurrent.MoreExecutors$Application.getExitingScheduledExecutorService(MoreExecutors.java:187)
at com.google.common.util.concurrent.MoreExecutors$Application.getExitingScheduledExecutorService(MoreExecutors.java:219)
at com.google.common.util.concurrent.MoreExecutors.getExitingScheduledExecutorService(MoreExecutors.java:169)
at com.google.api.gax.grpc.InstantiatingExecutorProvider.getExecutor(InstantiatingExecutorProvider.java:53)
at com.google.cloud.pubsub.spi.v1.Publisher.<init>(Publisher.java:128)
at com.google.cloud.pubsub.spi.v1.Publisher.<init>(Publisher.java:76)
at com.google.cloud.pubsub.spi.v1.Publisher$Builder.build(Publisher.java:642)

Basically it tried to add a shutdown hook which is not allowed.

What am I missing ?


Solution

  • The library doesn't support GAE standard environment yet, only flexible, see https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-pubsub

    This should be documented in Google documents instead of an instruction in Github