-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: collection is not associated with any session
PostPosted: Mon Sep 17, 2007 9:55 am 
Newbie

Joined: Mon Sep 17, 2007 9:37 am
Posts: 2
Location: Brooklyn
HibernateException: collection is not associated with any session

I'm getting this error message on the deployment server but not the development machine. Does this mean anything to anyone?

The code where it dies looks like this:

Query query = session.createQuery(
"FROM FooState WHERE Foo_ID=" + this.getFooID());
log.debug("before");
List<FooState> list = query.list();
log.debug("after");
try {
FooState state = list.get(0);
// We might be able to use lazy loading if we don't close here;
// but then how many sessions would be open?
return state;
}
finally {
session.close();
}

The specific line where it dies is

List<FooState> list = query.list();

It seems that sometime between the creating of the query and the executing of the query one line later, the session has somehow become null. Any ideas?


Hibernate version:

3

Full stack trace of any exception that occurs:

org.hibernate.HibernateException: collection is not associated with any session
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:449)
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:785)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:241)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at com.example.panda.controller.FooConfig.getFooState(FooConfig.java:170)
at com.example.panda.controller.FooController.loadScheduler(FooController.java:175)
at com.example.panda.controller.FooController.loadSchedulers(FooController.java:155)
at com.example.panda.controller.FooController.start(FooController.java:76)
at com.example.panda.controller.FooController.main(FooController.java:294)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
at org.apache.tools.ant.taskdefs.Java.run(Java.java:747)
at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:201)
at org.apache.tools.ant.taskdefs.Java.execute(Java.java:104)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.Main.runBuild(Main.java:698)
at org.apache.tools.ant.Main.startAnt(Main.java:199)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)


Name and version of the database you are using:

MySQL 5


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 17, 2007 10:57 am 
Newbie

Joined: Mon Sep 17, 2007 9:37 am
Posts: 2
Location: Brooklyn
FWIW, further investigation suggests a possible race condition. Subtle, semantically insignificant changes such as calling println once or twice mask the bug.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.