Google App Engine error Object Manager has been closed

Posted by newbie on Stack Overflow See other posts from Stack Overflow or by newbie
Published on 2010-06-03T18:52:36Z Indexed on 2010/06/03 18:54 UTC
Read the original article Hit count: 206

Filed under:

I had following error from Google App Engine when I was trying to iterate list in JSP page with EL.

Object Manager has been closed

I solved problem with following coe, but I don't think that it is very good solution to this problem:

public List<Item> getItems() {
        PersistenceManager pm = getPersistenceManager();
        Query query = pm.newQuery("select from " + Item.class.getName());
        List<Item> items = (List<Items>) query.execute();       
        List<Item> items2 = new ArrayList<Item>(); // This line solved my problem 
        Collections.copy(items, items2); // and this also 
        pm.close();
        return (List<Item>) items;
    }

When I tried to use pm.detachCopyAll(items) it gave same error. I understood that detachCopyAll() method should do same what I did, but that method should be part of data nucelus, so it should be used instead of my owm methods. So why dosen't detachCopyAll() work at all?

© Stack Overflow or respective owner

Related posts about google-app-engine