Start a new topic

"No active user" error after calling loginBlocking()

Hi, at the start of my App Engine custom endpoint I have:

javaClient = new Client.Builder(auth.getAppId(), auth.getMasterSecret()).build();

javaClient.user().loginBlocking(auth.getAppId(), auth.getMasterSecret()).execute();

if (javaClient.user().isUserLoggedIn()) {


So i am logging in as the "master user" and making sure I have a logged in user . However, later on in the same script's execution occasionally I will get a NullPointerException when trying to run a query against the data store:

java.lang.NullPointerException: No Active User - please login a user by calling myClient.user().login( ... ) before retrying this request.



Any ideas why this might be the case?
1 Comment


The Java library uses an in-memory implementation for storing credentials, which is referenced from the Client. I'm wondering if it is possible that the client is getting garbage collected at any point? How are you maintaining the reference to the Client? Also, are you calling `javaClient.User().Logout().Execute()` at any point?

As a temporary workaround, you can wrap access to the client behind a `getClient()` method, which will check if it's logged in, and if it's not perform a login operation.

Login or Signup to post a comment