【发布时间】:2014-05-06 19:56:39
【问题描述】:
我正在创建一个带有应用引擎后端的 android 应用程序。我使用 google app engine 插件创建了一个 android 连接的应用程序。这是我的实体。
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class User {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
Long id;
@Persistent
String email;
@Persistent
String password;
我使用插件来生成我的端点。为了测试它,我将应用引擎作为 Web 应用程序运行,并且我可以成功使用每种方法。我导航到
http://localhost:8888/_ah/admin/datastore
我可以看到我输入的记录。为了确保生成的 getUser 方法有效,我转到 API 资源管理器并检索 id = 1 的用户,然后我得到了
{ “id”:“1”, “电子邮件”:“this@that.com”, “密码”:“1234” }
所以我知道它有效。在我的 android 应用程序中,我像这样连接到端点:
User user = new User();
Userendpoint.Builder endpointBuilder = new Userendpoint.Builder(AndroidHttp.newCompatibleTransport(), new JacksonFactory(), new HttpRequestInitializer() {
public void initialize(HttpRequest httpRequest) {
}
});
Userendpoint endpoint = CloudEndpointUtils.updateBuilder(endpointBuilder).build();
try {
User result = endpoint.getUser(1L).execute();
} catch (IOException e) {
e.printStackTrace();
}
我收到以下错误
com.google.api.client.googleapis.json.GoogleJsonResponseException: 503 服务不可用 { “代码”:503, “错误”:[{ “域”:“全球”, “消息”:“javax.jdo.JDOObjectNotFoundException:无法检索具有键 User(1) 的用户类型实体\nNestedThrowables:\norg.datanucleus.exceptions.NucleusObjectNotFoundException:无法检索具有键 User(1) 的用户类型实体” , “原因”:“后端错误” }],
任何建议或想法将不胜感激!
【问题讨论】:
标签: java android google-app-engine google-cloud-datastore