`

GAE的一个bug(org.datanucleus.exceptions.NucleusUserException: Object Manager has b)

阅读更多

在GAE上用spring管理JPA之后,出现了一个莫名的错误

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

 也就是说这个东西自动关闭了,可是我已经使用Annotation声明过了呀

@Transactional

 

Problem accessing /admin/categories!find. Reason:

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

Caused by:

org.apache.jasper.JasperException: org.datanucleus.exceptions.NucleusUserException: Object Manager has been closed
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
	at com.google.appengine.tools.development.PrivilegedJspServlet.access$101(PrivilegedJspServlet.java:23)
	at com.google.appengine.tools.development.PrivilegedJspServlet$2.run(PrivilegedJspServlet.java:59)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.google.appengine.tools.development.PrivilegedJspServlet.service(PrivilegedJspServlet.java:57)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
	at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
	at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:327)
	at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:126)

 后来搜到有位老兄也出现相同的错误,墙出去看看

http://wagagate.appspot.com/gIjurxsv/http/group/google-appengine-java/browse_thread/thread/945f6ca66c1c587e

Luca 写道
org.datanucleus.exceptions.NucleusUserException: Object Manager has been closed

Hi,
i'm still trying to develop a simple application that store some
entities (Person) information. Currently i have developed a PersonDao
using Spring JdoTemplate.
I have a method that return me all entries contained in the repository
(i have only few entries..). That i like this:


public Collection<Person> findPeople() {
jdoTemplate.executeFind(
new JdoCallback()
{
public Collection<Project> doInJdo( PersistenceManager
persistentManager ) throws JDOException
{
Query query = persistentManager.newQuery( Person.class );
return (Collection<Person>) query.execute();
}
};
}



}


function findPeople work well. The problem occour when i want iterate
over collection returned by findPeople:

Collection<Person> foundPeople = findPeople();


for(Person person: foundPeople) { // here was threw
org.datanucleus.exceptions.NucleusUserException: Object Manager has
been closed
askSomethingTo(person);



}


As described here
http://code.google.com/p/datanucleus-appengine/issues/detail?id=24
that failure is caused by a bug (Anyone can confirm please?)

In this situation, the workaround described above works for me:


Query query = persistentManager.newQuery( Person.class );
List result = query.execute();
result.size();
return result;


Hope that can be useful.


Luca


 

个人觉得应该是lazy-load之类的东西,解决方法是在返回结果之后对结果集执行一次操作,可以是size()

分享到:
评论
1 楼 ember_319 2011-01-22  
这个问题啊,貌似是在PersistenceManager关闭前对象有效,如果希望在关闭后仍然使用该bean,就需要有操作……

相关推荐

Global site tag (gtag.js) - Google Analytics