1

Google cloud endpoints HTTP 500 error on delete

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

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:

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?

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

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

500 No content to map to Object due to end of input
Dewiniaeth
  • 1,123
  • 3
  • 18
  • 30

1 Answers1

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.

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.

Dan Holevoet
  • 9,183
  • 1
  • 33
  • 49
  • If I instead return null OR I change the method to a VOID, the resulting HTTP response is a "500 No content to map to Object due to end of input" I really just want to return an HTTP 200 - ideally with no content. – Dewiniaeth Apr 08 '13 at 12:13
  • Did you regenerate your client library after this? – Dan Holevoet Apr 08 '13 at 17:43
  • I'm not using a client library - I'm simply invoking an HTTP DELETE request using Fidder - I'm just writing the server side API. – Dewiniaeth Apr 08 '13 at 20:31
  • 1
    There appears to be an error in the dev appserver. I see a `204 No Content` in production, but the same error you report in the dev appserver. – Dan Holevoet Apr 08 '13 at 21:14
  • 1
    This should be fixed in the 1.7.7 release (including the pre-release SDK that's available now: https://code.google.com/p/googleappengine/downloads/detail?name=appengine-java-sdk-1.7.7_prerelease.zip) – Dan Holevoet Apr 08 '13 at 21:24
  • Thanks for investigating Dan. When can we expect the 1.7.7 final release? – Dewiniaeth Apr 09 '13 at 07:57
  • Hi Dan What is the issue number on the defect list on https://code.google.com/p/googleappengine/issues/list I would like to follow the progress – Dewiniaeth Apr 09 '13 at 15:03
  • It's not listed there as it was discovered and fixed by the team before you and I discovered it. I can't give you an exact date, but I would expect it soon. :) – Dan Holevoet Apr 09 '13 at 16:51