Objectify и TimerTask: API-среда для этой темы не зарегистрирована
я пытаюсь получитьTimerTask
настроить удаление записей из Google App Engine 'S DataStore периодически. Итак, я создалServletContextListener
с.Timer
ВнутриcontextInitialized
Я зарегистрировал свои классы Objectify:
ObjectifyService.register(Person.class);
Однако, когда задача действительно выполняется, она жалуется, что не была настроена среда API:
Exception in thread "Timer-0" java.lang.NullPointerException: No API environment is registered for this thread.
at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId(DatastoreApiHelper.java:80)
at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppIdNamespace(DatastoreApiHelper.java:90)
at com.google.appengine.api.datastore.Query.(Query.java:214)
at com.google.appengine.api.datastore.Query.(Query.java:143)
at com.googlecode.objectify.impl.cmd.QueryImpl.(QueryImpl.java:72)
at com.googlecode.objectify.impl.cmd.LoadTypeImpl.createQuery(LoadTypeImpl.java:50)
at com.googlecode.objectify.impl.cmd.LoadTypeImpl.filter(LoadTypeImpl.java:58)
at myApp.MyServletContextListener$MyTask.run(MyServletContextListener.java:58)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Есть идеи? Я'мы попытались изменить строку, которая регистрирует класс наObjectifyService.factory().register(Person.class);
но это некажется, чтобы помочь.