Why does the code below result in org.datanucleus.exceptions.NucleusUserException: Object Manager has been closed? The exception appears to be thrown at query.getResultList(
I don't know why exactly, but it seems to have to do with query.getResultList() being lazy-loaded. Apparently the lazy-loading breaks down when you call remove(token).
As a work-around can you collect the ids/keys for the elements in an ArrayList first, and in a separate loop remove them from the datastore?