-->
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: Failed to lazily initialize a collection - no Session
PostPosted: Wed Jan 28, 2004 9:12 pm 
Newbie

Joined: Wed Jan 28, 2004 9:04 pm
Posts: 7
In the samples I have seen the collections were mapped with the attribute lazy="true". I would prefer this option to improve performance however it causes the exception below. If I remove lazy="true" it runs ok.

What should I do to fix this problem?

Thanks.
Jerry.


<set name="transactions" cascade="all" inverse="true" lazy="true">
<key column="tnumber"/>
<one-to-many class="someClass"/>
</set>


11:57:57,980 ERROR LazyInitializationException:25 - Failed to lazily initialize
a collection - no Session
net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a coll
ection - no Session
at net.sf.hibernate.collection.PersistentCollection.initialize(Persisten
tCollection.java:213)
at net.sf.hibernate.collection.PersistentCollection.read(PersistentColle
ction.java:69)
at net.sf.hibernate.collection.Set.size(Set.java:107)
at au.com.countryenergy.legacyarchive.webapp.action.customer.ViewStoresA
ction.execute(ViewStoresAction.java:42)
at org.apache.struts.action.RequestProcessor.processActionPerform(Reques
tProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:148
2)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:204)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:256)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:564)
at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
ContextValve.java:245)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:199)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:564)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:195)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:164)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:564)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:156)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:564)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:21
1)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:805)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:696)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:605)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:677)
at java.lang.Thread.run(Thread.java:534)
11:57:58,027 WARN RequestProcessor:538 - Unhandled Exception thrown: class net.
sf.hibernate.LazyInitializationException


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 28, 2004 9:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Well, as you haven't posted any of the code driving the interaction which generates this error I guess we'll have to guess.

Most definitely you are closing the session prior to accessing the collection. How exactly that happens is in the details you left out of your post...


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.