org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed

Spring JIRA | Gopal Koratana | 1 decade ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    I was using Spring 1.0 with Hibernate2 for my DAO layer. Xdoclet is used to generate hibernate mapping. Spring among other thing is also used to manage transaction (declarative). This is working perfectly. I decided to upgrade to Hiebernate3 and hence Spring 1.2 RC2. Had to upgrade couple of hibernate and spring jar's. Figured out some of the methods in hibernate temple are gone but overall the migration was seamless. The systems build and deployes. BUT When I deploy the webapp (in Tomcat 5.0 and JDK 1.4.2), and make a DAO call and get the entity and try to access some property within the entity I am getting this exception Any Suggestions. Looks like I am missing some kind of configuration. Thanks Gopal ================================= org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:53) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134) at com.manheim.dms.entity.security.vo.Role$$EnhancerByCGLIB$$4ad14d28.getActive(<generated>) at com.manheim.dms.system.SecurityManager.buildProfile(SecurityManager.java:85) at com.manheim.dms.handler.AdminHandler.authenticate(AdminHandler.java:147) 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.cysive.framework.servlet.controller.ProxyRequestHandler.processRequest(ProxyRequestHandler.java:104) at com.cysive.framework.servlet.controller.Dispatcher.processAction(Dispatcher.java:1040) at com.cysive.framework.servlet.controller.Dispatcher.processRequest(Dispatcher.java:1081) at com.cysive.framework.servlet.controller.Dispatcher.doPost(Dispatcher.java:305) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) 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:118) 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:799) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) ================================

    Spring JIRA | 1 decade ago | Gopal Koratana
    org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
  2. 0

    I was using Spring 1.0 with Hibernate2 for my DAO layer. Xdoclet is used to generate hibernate mapping. Spring among other thing is also used to manage transaction (declarative). This is working perfectly. I decided to upgrade to Hiebernate3 and hence Spring 1.2 RC2. Had to upgrade couple of hibernate and spring jar's. Figured out some of the methods in hibernate temple are gone but overall the migration was seamless. The systems build and deployes. BUT When I deploy the webapp (in Tomcat 5.0 and JDK 1.4.2), and make a DAO call and get the entity and try to access some property within the entity I am getting this exception Any Suggestions. Looks like I am missing some kind of configuration. Thanks Gopal ================================= org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:53) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134) at com.manheim.dms.entity.security.vo.Role$$EnhancerByCGLIB$$4ad14d28.getActive(<generated>) at com.manheim.dms.system.SecurityManager.buildProfile(SecurityManager.java:85) at com.manheim.dms.handler.AdminHandler.authenticate(AdminHandler.java:147) 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.cysive.framework.servlet.controller.ProxyRequestHandler.processRequest(ProxyRequestHandler.java:104) at com.cysive.framework.servlet.controller.Dispatcher.processAction(Dispatcher.java:1040) at com.cysive.framework.servlet.controller.Dispatcher.processRequest(Dispatcher.java:1081) at com.cysive.framework.servlet.controller.Dispatcher.doPost(Dispatcher.java:305) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) 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:118) 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:799) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) ================================

    Spring JIRA | 1 decade ago | Gopal Koratana
    org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
  3. 0

    How can i wire-up org.springframework.transaction.interceptor.TransactionProxyFactoryBean and org.springframework.orm.hibernate3.HibernateInterceptor?

    Stack Overflow | 7 years ago | Wall-E
    org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Hibernate Community • View topic - object references an unsaved transient instance

    hibernate.org | 1 year ago
    org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
  6. 0

    Hibernate Community • View topic - org.hibernate.LazyInitializationException ????

    hibernate.org | 9 months ago
    org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.LazyInitializationException

      could not initialize proxy - the owning Session was closed

      at org.hibernate.proxy.AbstractLazyInitializer.initialize()
    2. Hibernate
      CGLIBLazyInitializer.intercept
      1. org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:53)
      2. org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80)
      3. org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
      3 frames
    3. com.manheim.dms
      AdminHandler.authenticate
      1. com.manheim.dms.entity.security.vo.Role$$EnhancerByCGLIB$$4ad14d28.getActive(<generated>)
      2. com.manheim.dms.system.SecurityManager.buildProfile(SecurityManager.java:85)
      3. com.manheim.dms.handler.AdminHandler.authenticate(AdminHandler.java:147)
      3 frames
    4. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:324)
      4 frames
    5. com.cysive.framework
      Dispatcher.doPost
      1. com.cysive.framework.servlet.controller.ProxyRequestHandler.processRequest(ProxyRequestHandler.java:104)
      2. com.cysive.framework.servlet.controller.Dispatcher.processAction(Dispatcher.java:1040)
      3. com.cysive.framework.servlet.controller.Dispatcher.processRequest(Dispatcher.java:1081)
      4. com.cysive.framework.servlet.controller.Dispatcher.doPost(Dispatcher.java:305)
      4 frames
    6. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
      2. javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      2 frames
    7. Glassfish Core
      ContainerBase.invoke
      1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      3. org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
      4. org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      5. org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      6. org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
      7. org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
      8. org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      9. org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      10. org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
      11. org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      12. org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
      13. org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
      14. org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      15. org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      16. org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      17. org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      18. org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
      18 frames
    8. org.apache.coyote
      CoyoteAdapter.service
      1. org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
      1 frame
    9. Grizzly HTTP
      TcpWorkerThread.runIt
      1. org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
      2. org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
      3. org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
      3 frames