net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed

Atlassian JIRA | Piotr Stefan Stefaniak [Atlassian] | 7 years ago
  1. 0

    While using [bamboo plugin tutorial|http://confluence.atlassian.com/display/BAMBOO/Tutorial+1+-+Getting+Started+with+a+Simple+Post+Build+Labeller] i've encountered following Exception: ---- 2010-04-09 20:52:40,190 ERROR [BAM::Events:pool-1-thread-1] [LazyInitializationException] 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.write(PersistentCollection.java:84) at net.sf.hibernate.collection.Bag.add(Bag.java:281) at com.atlassian.bamboo.labels.LabelManagerImpl.addLabel(LabelManagerImpl.java:393) at com.atlassian.bamboo.labels.LabelManagerImpl.addLabel(LabelManagerImpl.java:57) 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:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at com.atlassian.bamboo.security.acegi.intercept.aopalliance.AuthorityOverrideMethodSecurityInterceptor.invoke(AuthorityOverrideMethodSecurityInterceptor.java:30) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy27.addLabel(Unknown Source) 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:597) at com.atlassian.plugin.osgi.hostcomponents.impl.DefaultComponentRegistrar$ContextClassLoaderSettingInvocationHandler.invoke(DefaultComponentRegistrar.java:129) at $Proxy77.addLabel(Unknown Source) 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:597) at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:150) at $Proxy77.addLabel(Unknown Source) at com.mycompany.bamboo.plugins.BuildLabeller.run(BuildLabeller.java:30) at com.atlassian.bamboo.v2.build.events.PostBuildCompletedEventListener.performCustomBuildCompleteAction(PostBuildCompletedEventListener.java:68) at com.atlassian.bamboo.v2.build.events.PostBuildCompletedEventListener.handleEvent(PostBuildCompletedEventListener.java:41) at com.atlassian.bamboo.event.BambooEventManager$2.run(BambooEventManager.java:47) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at com.atlassian.bamboo.build.pipeline.concurrent.NamedThreadFactory$1.run(NamedThreadFactory.java:33) at java.lang.Thread.run(Thread.java:619) ---- steps to reproduce: 1. Use atlassian-plugin-sdk to create new plugin. 2. Use [aforementioned bamboo plugin tutorial|http://confluence.atlassian.com/display/BAMBOO/Tutorial+1+-+Getting+Started+with+a+Simple+Post+Build+Labeller] to create simple BuildCompleteAction. 3. Run build, which returns in logs "OutOfMemoryError" (for example: Script = '-c echo OutOfMemoryError')

    Atlassian JIRA | 7 years ago | Piotr Stefan Stefaniak [Atlassian]
    net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed
  2. 0

    While using [bamboo plugin tutorial|http://confluence.atlassian.com/display/BAMBOO/Tutorial+1+-+Getting+Started+with+a+Simple+Post+Build+Labeller] i've encountered following Exception: ---- 2010-04-09 20:52:40,190 ERROR [BAM::Events:pool-1-thread-1] [LazyInitializationException] 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.write(PersistentCollection.java:84) at net.sf.hibernate.collection.Bag.add(Bag.java:281) at com.atlassian.bamboo.labels.LabelManagerImpl.addLabel(LabelManagerImpl.java:393) at com.atlassian.bamboo.labels.LabelManagerImpl.addLabel(LabelManagerImpl.java:57) 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:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at com.atlassian.bamboo.security.acegi.intercept.aopalliance.AuthorityOverrideMethodSecurityInterceptor.invoke(AuthorityOverrideMethodSecurityInterceptor.java:30) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy27.addLabel(Unknown Source) 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:597) at com.atlassian.plugin.osgi.hostcomponents.impl.DefaultComponentRegistrar$ContextClassLoaderSettingInvocationHandler.invoke(DefaultComponentRegistrar.java:129) at $Proxy77.addLabel(Unknown Source) 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:597) at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:150) at $Proxy77.addLabel(Unknown Source) at com.mycompany.bamboo.plugins.BuildLabeller.run(BuildLabeller.java:30) at com.atlassian.bamboo.v2.build.events.PostBuildCompletedEventListener.performCustomBuildCompleteAction(PostBuildCompletedEventListener.java:68) at com.atlassian.bamboo.v2.build.events.PostBuildCompletedEventListener.handleEvent(PostBuildCompletedEventListener.java:41) at com.atlassian.bamboo.event.BambooEventManager$2.run(BambooEventManager.java:47) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at com.atlassian.bamboo.build.pipeline.concurrent.NamedThreadFactory$1.run(NamedThreadFactory.java:33) at java.lang.Thread.run(Thread.java:619) ---- steps to reproduce: 1. Use atlassian-plugin-sdk to create new plugin. 2. Use [aforementioned bamboo plugin tutorial|http://confluence.atlassian.com/display/BAMBOO/Tutorial+1+-+Getting+Started+with+a+Simple+Post+Build+Labeller] to create simple BuildCompleteAction. 3. Run build, which returns in logs "OutOfMemoryError" (for example: Script = '-c echo OutOfMemoryError')

    Atlassian JIRA | 7 years ago | Piotr Stefan Stefaniak [Atlassian]
    net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed
  3. 0

    {code} 2008-02-10 00:00:00,163 INFO [QuartzScheduler_Worker-4] [BuildExpiryBean] Found 59 builds to expire. 2008-02-10 00:00:00,164 ERROR [QuartzScheduler_Worker-4] [LazyInitializationException] 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.iterator(Bag.java:256) at com.atlassian.bamboo.resultsummary.BuildResultsSummaryImpl.getLabelNames(BuildResultsSummaryImpl.java:213) at com.atlassian.bamboo.build.expiry.BuildExpiryBean.excludedDueToLabel(BuildExpiryBean.java:197) at com.atlassian.bamboo.build.expiry.BuildExpiryBean.expireBuild(BuildExpiryBean.java:160) at com.atlassian.bamboo.build.expiry.BuildExpiryBean.expireAllBuilds(BuildExpiryBean.java:86) at com.atlassian.bamboo.build.expiry.ExpiredBuildCleaner.execute(ExpiredBuildCleaner.java:25) at org.quartz.core.JobRunShell.run(JobRunShell.java:203) at com.atlassian.bamboo.quartz.SystemAuthorizedThreadPool$1.run(SystemAuthorizedThreadPool.java:36) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520) 2008-02-10 00:00:00,167 ERROR [QuartzScheduler_Worker-4] [JobRunShell] Job DEFAULT.removeExpiredBuilds threw an unhandled Exception: 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.iterator(Bag.java:256) at com.atlassian.bamboo.resultsummary.BuildResultsSummaryImpl.getLabelNames(BuildResultsSummaryImpl.java:213) at com.atlassian.bamboo.build.expiry.BuildExpiryBean.excludedDueToLabel(BuildExpiryBean.java:197) at com.atlassian.bamboo.build.expiry.BuildExpiryBean.expireBuild(BuildExpiryBean.java:160) at com.atlassian.bamboo.build.expiry.BuildExpiryBean.expireAllBuilds(BuildExpiryBean.java:86) at com.atlassian.bamboo.build.expiry.ExpiredBuildCleaner.execute(ExpiredBuildCleaner.java:25) at org.quartz.core.JobRunShell.run(JobRunShell.java:203) at com.atlassian.bamboo.quartz.SystemAuthorizedThreadPool$1.run(SystemAuthorizedThreadPool.java:36) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520) 2008-02-10 00:00:00,170 ERROR [QuartzScheduler_Worker-4] [ErrorLogger] Job (DEFAULT.removeExpiredBuilds threw an exception. org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed] at org.quartz.core.JobRunShell.run(JobRunShell.java:214) at com.atlassian.bamboo.quartz.SystemAuthorizedThreadPool$1.run(SystemAuthorizedThreadPool.java:36) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520) * Nested Exception (Underlying Cause) --------------- 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.iterator(Bag.java:256) at com.atlassian.bamboo.resultsummary.BuildResultsSummaryImpl.getLabelNames(BuildResultsSummaryImpl.java:213) at com.atlassian.bamboo.build.expiry.BuildExpiryBean.excludedDueToLabel(BuildExpiryBean.java:197) at com.atlassian.bamboo.build.expiry.BuildExpiryBean.expireBuild(BuildExpiryBean.java:160) at com.atlassian.bamboo.build.expiry.BuildExpiryBean.expireAllBuilds(BuildExpiryBean.java:86) at com.atlassian.bamboo.build.expiry.ExpiredBuildCleaner.execute(ExpiredBuildCleaner.java:25) at org.quartz.core.JobRunShell.run(JobRunShell.java:203) at com.atlassian.bamboo.quartz.SystemAuthorizedThreadPool$1.run(SystemAuthorizedThreadPool.java:36) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520){code}

    Atlassian JIRA | 9 years ago | Ajay Sridhar [Atlassian]
    net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Enabling caching for hibernate repository by adding the *cache="true"* directive in the atlassian-user.xml file, such as this: {noformat} <hibernate name="Hibernate Repository" key="hibernateRepository" description="Hibernate Repository" cache="true" /> {noformat} leads to the following exception: {noformat} Cause: 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) Stack Trace: [hide] 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.Set.contains(Set.java:122) at com.atlassian.user.impl.hibernate.HibernateGroupManager.hasExternalMembership(HibernateGroupManager.java:461) at com.atlassian.user.impl.hibernate.HibernateGroupManager.hasMembership(HibernateGroupManager.java:437) at com.atlassian.user.impl.cache.CachingGroupManager.hasMembership(CachingGroupManager.java:149) at com.atlassian.user.impl.delegation.DelegatingGroupManagerTemplate.hasMembership(DelegatingGroupManagerTemplate.java:189) {noformat}

    Atlassian JIRA | 9 years ago | Gurleen Anand [Atlassian]
    net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed
  6. 0

    Enabling caching for hibernate repository by adding the *cache="true"* directive in the atlassian-user.xml file, such as this: {noformat} <hibernate name="Hibernate Repository" key="hibernateRepository" description="Hibernate Repository" cache="true" /> {noformat} leads to the following exception: {noformat} Cause: 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) Stack Trace: [hide] 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.Set.contains(Set.java:122) at com.atlassian.user.impl.hibernate.HibernateGroupManager.hasExternalMembership(HibernateGroupManager.java:461) at com.atlassian.user.impl.hibernate.HibernateGroupManager.hasMembership(HibernateGroupManager.java:437) at com.atlassian.user.impl.cache.CachingGroupManager.hasMembership(CachingGroupManager.java:149) at com.atlassian.user.impl.delegation.DelegatingGroupManagerTemplate.hasMembership(DelegatingGroupManagerTemplate.java:189) {noformat}

    Atlassian JIRA | 9 years ago | Gurleen Anand [Atlassian]
    net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or 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. net.sf.hibernate.LazyInitializationException

      Failed to lazily initialize a collection - no session or session was closed

      at net.sf.hibernate.collection.PersistentCollection.initialize()
    2. net.sf.hibernate
      Bag.add
      1. net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:209)
      2. net.sf.hibernate.collection.PersistentCollection.write(PersistentCollection.java:84)
      3. net.sf.hibernate.collection.Bag.add(Bag.java:281)
      3 frames
    3. com.atlassian.bamboo
      LabelManagerImpl.addLabel
      1. com.atlassian.bamboo.labels.LabelManagerImpl.addLabel(LabelManagerImpl.java:393)
      2. com.atlassian.bamboo.labels.LabelManagerImpl.addLabel(LabelManagerImpl.java:57)
      2 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:597)
      4 frames
    5. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
      2. org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
      3. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
      3 frames
    6. com.atlassian.bamboo
      AuthorityOverrideMethodSecurityInterceptor.invoke
      1. com.atlassian.bamboo.security.acegi.intercept.aopalliance.AuthorityOverrideMethodSecurityInterceptor.invoke(AuthorityOverrideMethodSecurityInterceptor.java:30)
      1 frame
    7. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
      2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
      2 frames
    8. Unknown
      $Proxy27.addLabel
      1. $Proxy27.addLabel(Unknown Source)
      1 frame
    9. 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:597)
      4 frames
    10. com.atlassian.plugin
      DefaultComponentRegistrar$ContextClassLoaderSettingInvocationHandler.invoke
      1. com.atlassian.plugin.osgi.hostcomponents.impl.DefaultComponentRegistrar$ContextClassLoaderSettingInvocationHandler.invoke(DefaultComponentRegistrar.java:129)
      1 frame
    11. Unknown
      $Proxy77.addLabel
      1. $Proxy77.addLabel(Unknown Source)
      1 frame
    12. 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:597)
      4 frames
    13. com.atlassian.plugin
      HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke
      1. com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:150)
      1 frame
    14. Unknown
      $Proxy77.addLabel
      1. $Proxy77.addLabel(Unknown Source)
      1 frame
    15. com.mycompany.bamboo
      BuildLabeller.run
      1. com.mycompany.bamboo.plugins.BuildLabeller.run(BuildLabeller.java:30)
      1 frame
    16. com.atlassian.bamboo
      BambooEventManager$2.run
      1. com.atlassian.bamboo.v2.build.events.PostBuildCompletedEventListener.performCustomBuildCompleteAction(PostBuildCompletedEventListener.java:68)
      2. com.atlassian.bamboo.v2.build.events.PostBuildCompletedEventListener.handleEvent(PostBuildCompletedEventListener.java:41)
      3. com.atlassian.bamboo.event.BambooEventManager$2.run(BambooEventManager.java:47)
      3 frames
    17. Java RT
      ThreadPoolExecutor$Worker.run
      1. java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      2 frames
    18. com.atlassian.bamboo
      NamedThreadFactory$1.run
      1. com.atlassian.bamboo.build.pipeline.concurrent.NamedThreadFactory$1.run(NamedThreadFactory.java:33)
      1 frame
    19. Java RT
      Thread.run
      1. java.lang.Thread.run(Thread.java:619)
      1 frame