1

I am getting the following error message:

org.datanucleus.exceptions.NucleusUserException: Object Manager has been closed

I have read up on everything I could find on it but I still don't understand what is causing it. I am about to give up and switch to an SQL DB if I cannot resolve this simple issue. Yes I am closing the pm:

static void persistAll(Object[] objs) {

PersistenceManager pm = PMF.get().getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
  tx.begin();
  for (Object o : objs)
    pm.makePersistent(o);
  //pm.makePersistentAll(objs);
  tx.commit();
} finally {
  if (tx.isActive())
    tx.rollback();
  pm.close();
}

}

I've made my stuff detachable, and I have detached my objects where I thought I had to. What can I do now??? I'm completely stuck on this one!!! DataNucleus, please help!!!

JG

I have tried adding the Store's List<> fields to the default fetch group and I get the following warning errors from Jetty when debugging my application. I am going to have to try "touching" the fields instead when I fetch the stuff. (?)

Jan 29, 2012 1:29:30 PM org.datanucleus.store.appengine.MetaDataValidator warn
WARNING: Meta-data warning for com.foobar.foo.Store.sales: The datastore does not support joins and therefore cannot honor requests to place related objects in the default fetch group.  The field will be fetched lazily on first access.  You can modify this warning by setting the datanucleus.appengine.ignorableMetaDataBehavior property in your config.  A value of NONE will silence the warning.  A value of ERROR will turn the warning into an exception.
Jan 29, 2012 1:29:30 PM org.datanucleus.store.appengine.MetaDataValidator warn
WARNING: Meta-data warning for com.foobar.foo.Store.shipments: The datastore does not support joins and therefore cannot honor requests to place related objects in the default fetch group.  The field will be fetched lazily on first access.  You can modify this warning by setting the datanucleus.appengine.ignorableMetaDataBehavior property in your config.  A value of NONE will silence the warning.  A value of ERROR will turn the warning into an exception.
Jan 29, 2012 1:29:30 PM org.datanucleus.store.appengine.MetaDataValidator warn
WARNING: Meta-data warning for com.foobar.foo.Store.users: The datastore does not support joins and therefore cannot honor requests to place related objects in the default fetch group.  The field will be fetched lazily on first access.  You can modify this warning by setting the datanucleus.appengine.ignorableMetaDataBehavior property in your config.  A value of NONE will silence the warning.  A value of ERROR will turn the warning into an exception.

I am getting a NullPointerException from pm.makePersistent(store) even though I've checked with the debugger that store is not null (but, since the default fetch group is not working it may be that some of those subfields were null somehow (?)

1 Answer 1

5

I suspect that your issue relates to trying to access the value of a field which is lazily loaded. If you do this after the PersistenceManager is closed, it will be an error. For example, lazy loading is the default for child objects in a JDO owned relationship. Make sure that you fetch or access ("touch") such content before closing the pm and detaching the object. With an owned one-to-one relationship, you can also add the child field to the 'default fetch group' so it's retrieved and loaded with the parent.

There's more of a discussion on this here: http://code.google.com/appengine/docs/java/datastore/jdo/relationships.html#Owned_One_to_One_Relationships

2
  • Thank you for your reply, but as shown above app engine is not letting me use default fetch groups for my List<> object attributes. I am indeed touching the List<> and even detaching it so I don't know why I am getting a NullPointerException when I pm.makePersistent(). Any help greatly appreciated. JG Jan 29, 2012 at 13:20
  • 1
    Yes, with a m:1 owned relationship you will see the 'does not support joins' warning, and cannot use the default fetch group specification for the child collection. (Sorry, I missed that in your description). You will thus have to explicitly access the children in the collection before closing the pm -- and any lazily-loaded fields in the child objects that you need to access as well.
    – Amy U.
    Jan 29, 2012 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.