Google云终止了删除时的HTTP 500错误

时间:2021-02-20 23:10:49

Google cloud endpoints HTTP 500 error on delete

Google云终止了删除时的HTTP 500错误

I generated a Google Cloud Endpoint class which game me the standard CRUD methods including the delete method:

我生成了一个Google Cloud Endpoint类,它为我提供了标准的CRUD方法,包括delete方法:

public Member removeMember(@Named("id") Long id) {
    PersistenceManager mgr = getPersistenceManager();
    Member member = null;
    try {
        member = mgr.getObjectById(Member.class, id);
        mgr.deletePersistent(member);
    } finally {
        mgr.close();
    }
    return member;
}

However when I invoke a DELETE I get a HTTP 500 error returned:

但是当我调用DELETE时,我收到了一个HTTP 500错误:

HTTP ERROR 500

Problem accessing /_ah/spi/Members.removeMember. Reason:

com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException: Cannot read fields from a deleted object (through reference chain: com.mylodge.contracts.masonry.Member[\"degree\"])

How can I avoid this HTTP 500 error?

如何避免此HTTP 500错误?

Aside: To me it seems illogical to return the deleted object anyway. Wouldn't a HTTP 200 OK be more appropriate?

旁白:对我来说,无论如何返回已删除的对象似乎是不合逻辑的。 HTTP 200 OK不是更合适吗?

UPDATE: I have tried return null instead, and tried making the method a VOID. But both of these yield an HTTP response of

更新:我尝试返回null,并尝试使该方法成为一个VOID。但这两者都会产生HTTP响应

500 No content to map to Object due to end of input

1 个解决方案

#1


1  

If you don't want the object, don't return it. That's the easiest solution here. I'm going to suggest to the Google Plugin for Eclipse team that they change the template to not return the deleted object by default.

如果您不想要该对象,请不要将其返回。这是最简单的解决方案。我将向Google Plugin for Eclipse团队建议他们更改模板以默认不返回已删除的对象。

If you do want the deleted object, I think you're running into JDO's lazy loading. Your property degree is being loaded at serialization time. However, since the underlying datastore object is already deleted, it can't access it. You'll need to explicitly access the property before it gets deleted.

如果你确实想要删除对象,我认为你正在运行JDO的延迟加载。您的财产学位是在序列化时加载的。但是,由于基础数据存储区对象已被删除,因此无法访问它。您需要在删除之前显式访问该属性。

#1


1  

If you don't want the object, don't return it. That's the easiest solution here. I'm going to suggest to the Google Plugin for Eclipse team that they change the template to not return the deleted object by default.

如果您不想要该对象,请不要将其返回。这是最简单的解决方案。我将向Google Plugin for Eclipse团队建议他们更改模板以默认不返回已删除的对象。

If you do want the deleted object, I think you're running into JDO's lazy loading. Your property degree is being loaded at serialization time. However, since the underlying datastore object is already deleted, it can't access it. You'll need to explicitly access the property before it gets deleted.

如果你确实想要删除对象,我认为你正在运行JDO的延迟加载。您的财产学位是在序列化时加载的。但是,由于基础数据存储区对象已被删除,因此无法访问它。您需要在删除之前显式访问该属性。