【发布时间】:2015-05-01 03:42:51
【问题描述】:
我正在使用端点尝试为我的 Web 应用程序创建一个患者实体。当我尝试运行 API 时,我不断收到以下错误代码。
503 Service Unavailable
- Show headers -
{
"error": {
"errors": [
{
"domain": "global",
"reason": "backendError",
"message": "java.lang.IllegalStateException: 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."
}
],
"code": 503,
"message": "java.lang.IllegalStateException: 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."
}
}
我知道这与静态 ofy 文件有关,我不确定如何向其中添加过滤器。 这是我的静态对象化文件的代码。
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyService;
public class OfyService
{
public static Objectify ofy()
{
return ObjectifyService.ofy();
}
}
然后我在API类中使用这个方法调用ofy文件
ofy().save().entity(patient).now();
【问题讨论】:
标签: java google-app-engine google-cloud-endpoints objectify