【问题标题】:JDOObjectNotFoundException when retrieving data from datastore in Android application从 Android 应用程序中的数据存储区检索数据时出现 JDOObjectNotFoundException
【发布时间】: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


    【解决方案1】:

    错误是我正在从我的笔记本电脑连接到开发服务器,但我正在连接到我的设备上的生产服务器。

    改变

    // For development server
    protected static final String LOCAL_APP_ENGINE_SERVER_URL_FOR_ANDROID = "http://<Your IP>:<your port>/_ah/api";
    
    // For production server
    protected static final String LOCAL_APP_ENGINE_SERVER_URL_FOR_ANDROID = "https://<your version>-<your project ID>.appspot.com/_ah/api/";
    

    【讨论】:

      猜你喜欢
      • 2018-03-09
      • 1970-01-01
      • 1970-01-01
      • 2016-07-15
      • 1970-01-01
      • 2015-10-09
      • 2012-06-04
      • 1970-01-01
      • 2018-05-15
      相关资源
      最近更新 更多