-->
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.  [ 3 posts ] 
Author Message
 Post subject: Lazy Initialization Failure
PostPosted: Mon Nov 01, 2004 4:50 pm 
Beginner
Beginner

Joined: Tue Oct 26, 2004 4:59 pm
Posts: 23
I'm trying my hand at lazy initializing for the first time and got this exception. There is a session open in my method GroupActions.doAddPages().

Thanks,
Karl

Code:
SEVERE: Failed to lazily initialize a collection - no session or session was closed
net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed
   at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:209)
   at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)
   at net.sf.hibernate.collection.Bag.contains(Bag.java:248)
   at com.iws.model.page.Page.isGroupAuthorizedToAccessPage(Page.java:117)
   at com.iws.actions.GroupActions.doAddPages(GroupActions.java:143)
   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:324)
   at com.opensymphony.xwork.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:302)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:170)
   at com.opensymphony.xwork.interceptor.DefaultWorkflowInterceptor.intercept(DefaultWorkflowInterceptor.java:55)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.iws.auth.SecurityInterceptor.intercept(SecurityInterceptor.java:42)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:115)
   at com.opensymphony.xwork.ActionChainResult.execute(ActionChainResult.java:115)
   at com.opensymphony.xwork.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:263)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:187)
   at com.opensymphony.xwork.interceptor.DefaultWorkflowInterceptor.intercept(DefaultWorkflowInterceptor.java:55)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.iws.auth.SecurityInterceptor.intercept(SecurityInterceptor.java:42)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
   at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:115)
   at com.opensymphony.webwork.dispatcher.ServletDispatcher.serviceAction(ServletDispatcher.java:282)
   at com.opensymphony.webwork.dispatcher.ServletDispatcher.service(ServletDispatcher.java:252)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
   at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
   at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
   at java.lang.Thread.run(Thread.java:536)
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 01, 2004 4:56 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
yes but your instance is surely detached.
try session.lock or session.update before GroupActions.doAddPages().

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 01, 2004 5:27 pm 
Beginner
Beginner

Joined: Tue Oct 26, 2004 4:59 pm
Posts: 23
Thanks. Here is a cut of my code form the doAddPages method. If I understand correctly, my group object, newGroup, is persisted via the load method. The Page object that is being used in the line throwing the Exception is not. So you're saying I need to persist that page object? There's a method call that generates the collection of Page objects above what I've included. These are generated using session.find. In that method, once I call session.close those page objects are now detached, is that correct?

Karl

Code:
            session = HibernateSessionFactory.getSessionFactory().openSession(ConnectionProperties.getConn("iwsdb"));
         Group newGroup = (Group)session.load(Group.class, groupNo);
         while(it.hasNext()) {
            page = (Page) it.next();
            if(!tempMod.equals(page.getPageModule())) {
               if(counter != 1) {
                  pages.put(tempMod, pagesInModule);
               }
               pagesInModule = new ArrayList();
               tempMod = page.getPageModule();   
            }
            if(page.isGroupAuthorizedToAccessPage(newGroup)) {
               page.setGroupHasAccess(true);
            }
            pagesInModule.add(page);
            counter++;
         }


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.