org.datanucleus.exceptions.NucleusUserException:对象管理器已关闭 [英] org.datanucleus.exceptions.NucleusUserException: Object Manager has been closed

查看:886
本文介绍了org.datanucleus.exceptions.NucleusUserException:对象管理器已关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



org.datanucleus.exceptions.NucleusUserException:对象管理器已关闭



我已经阅读了关于它的所有内容,但我仍然不明白
是什么造成的。我即将放弃并切换到SQL数据库,如果我不能
解决这个简单的问题。是的,我正在关闭下午:



static void persistAll(Object [] objs){

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

}

我已经让我的东西可拆卸了,并且我已经分离了我认为必须的
的对象。我现在能做什么???我完全卡在这一个!
DataNucleus,请帮忙!!!

JG



我已经尝试添加Store's List< >字段设置为默认提取组,并在调试我的应用程序时从Jetty中获得以下警告错误。当我取东西时,我将不得不尝试触摸字段。 (?)

  2012年1月29日下午1:29:30 org.datanucleus.store.appengine.MetaDataValidator warn 
警告:com.foobar.foo.Store.sales的元数据警告:数据存储区不支持连接,因此无法遵守将相关对象放置在默认获取组中的请求。第一次访问时,该字段将被懒惰地提取。您可以通过在配置中设置datanucleus.appengine.ignorableMetaDataBehavior属性来修改此警告。值NONE将使警告消失。 ERROR值会将警告转变为异常。
2012年1月29日下午1:29:30 org.datanucleus.store.appengine.MetaDataValidator警告
警告:com.foobar.foo.Store.shipments的元数据警告:数据存储区不支持加入并因此无法兑现将相关对象放置在默认提取组中的请求。第一次访问时,该字段将被懒惰地提取。您可以通过在配置中设置datanucleus.appengine.ignorableMetaDataBehavior属性来修改此警告。值NONE将使警告消失。 ERROR值会将警告转变为异常。
2012年1月29日下午1:29:30 org.datanucleus.store.appengine.MetaDataValidator警告
警告:com.foobar.foo.Store.users的元数据警告:数据存储不支持加入并因此无法兑现将相关对象放置在默认提取组中的请求。第一次访问时,该字段将被懒惰地提取。您可以通过在配置中设置datanucleus.appengine.ignorableMetaDataBehavior属性来修改此警告。值NONE将使警告消失。 ERROR值会将警告转变为异常。

我从<$获得 NullPointerException c $ c> pm.makePersistent(store),尽管我已经用调试器检查过store不是null(但是,由于默认的读取组不工作,它可能是某些子字段是空的某种方式(?)

解决方案

我怀疑你的问题涉及到试图访问一个字段的值是懒惰加载。如果您在PersistenceManager关闭后执行此操作,则会出现错误。例如,延迟加载是JDO拥有关系中的子对象的默认值。
确保您获取或访问(touch)这样的内容在关闭pm和分离对象之前拥有一对一的关系,您还可以将子字段添加到默认获取组,以便检索并加载到父项。



这里有更多的讨论: http://code.google.com/appengine/docs/java/datastore/jdo/relationships.html#Owned_One_to_One_Relationships


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 (?)

解决方案

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

这篇关于org.datanucleus.exceptions.NucleusUserException:对象管理器已关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆