I tried to use both ObjectifyService.run() and begin() - always getting the same error.
For example, when using run() (I'm aware VoidWork is deprecated, but it's still supposed to work, isn't it?):
ObjectifyService.run(new VoidWork() {
@Override
public void vrun() {
ObjectifyService.register(MyObject.class);
MyObject myObj = ObjectifyService.ofy().load().type(MyObject.class).list();
//then edit myObj and write it to the Datastore
}
});
Failed to execute com.example.Example java.lang.IllegalStateException: You must call ObjectifyService.init() before using Objectify at com.google.common.base.Preconditions.checkState(Preconditions.java:511) at
com.googlecode.objectify.ObjectifyService.factory(ObjectifyService.java:34) at
com.googlecode.objectify.ObjectifyService.begin(ObjectifyService.java:80) at
com.googlecode.objectify.ObjectifyService.run(ObjectifyService.java:67) at
com.example.Example.accept(Example.java:27) at
com.example.Example.accept(Example.java:20) at com.google.cloud.functions.invoker.NewBackgroundFunctionExecutor$TypedFunctionExecutor.serviceLegacyEvent(NewBackgroundFunctionExecutor.java:258) at
...