with the latest version of Objectify (5.1), am getting following error when i try to access the ofy() method
You have not started an Objectify context. You are probably missing the ObjectifyFilter. If you are not running in the context of an http request, see the ObjectifyService.run() method.
i am running it from appengine web application, same code and configuration worked fine in older versions
following is my configuration, similar to the example provided in objectify documentation
web.xml
<filter>
<filter-name>ObjectifyFilter</filter-name>
<filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ObjectifyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
OfyService class
public class OfyService {
static {
long start = System.currentTimeMillis();
factory().register(User.class);
log.info(" Entity Registration took : {} ms", (System.currentTimeMillis() - start));
}
public static Objectify ofy() {
return ObjectifyService.ofy();
}
public static ObjectifyFactory factory() {
return (ObjectifyFactory) ObjectifyService.factory();
}
}
but i do defined ObjectifyFilter , any idea why am i getting this error? and how can i fix it?
Thanks!
UPDATE:
I have updated the objectify version to v5.1.5 but still the issue is not resolved any update on this?
Closeable closeable = begin();
before andcloseable.close();
after to avoid the error you got. Note that begin() comes from doingimport static com.googlecode.objectify.ObjectifyService.begin;
– Catechism