org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.localizationManagerImpl': Scope 'session' is not active for the current thread; ... In my concrete case, applicationManagerImpl tries to remove an event listener from localizationManagerImpl. Of course, he only knows about the interface, so he is not aware of the fact that localizationManagerImpl is also session scoped (deregistration of listener is not really necessary). The problem is caused by the missing HttpServletRequest, which usually carries the session. When sessions expire, no request is active, so the RequestContextHolder has no RequestAttributes

Spring JIRA | Sebastian Paul | 4 years ago
  1. 0

    Destroy method of session scoped bean cannot access other session scoped bean: CommonAnnotationBeanPostProcessor - postProcessBeforeDestruction - Invocation of destroy method failed on bean with name 'scopedTarget.applicationManagerImpl': org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.localizationManagerImpl': Scope 'session' is not active for the current thread; ... In my concrete case, applicationManagerImpl tries to remove an event listener from localizationManagerImpl. Of course, he only knows about the interface, so he is not aware of the fact that localizationManagerImpl is also session scoped (deregistration of listener is not really necessary). The problem is caused by the missing HttpServletRequest, which usually carries the session. When sessions expire, no request is active, so the RequestContextHolder has no RequestAttributes at org.springframework.web.context.request.DestructionCallbackBindingListener.valueUnbound(DestructionCallbackBindingListener.java:51) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE] at org.apache.catalina.session.StandardSession.removeAttributeInternal(StandardSession.java:1710) [catalina.jar:6.0.35.B] at org.apache.catalina.session.StandardSession.expire(StandardSession.java:812) [catalina.jar:6.0.35.B] at org.apache.catalina.session.StandardSession.isValid(StandardSession.java:587) [catalina.jar:6.0.35.B] at org.apache.catalina.session.ManagerBase.processExpires(ManagerBase.java:714) [catalina.jar:6.0.35.B] at org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:699) [catalina.jar:6.0.35.B] at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1368) [catalina.jar:6.0.35.B] at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1653) [catalina.jar:6.0.35.B] at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1662) [catalina.jar:6.0.35.B] at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1662) [catalina.jar:6.0.35.B] at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1642) [catalina.jar:6.0.35.B] Spring should handle this by setting up a RequestAttributes instance which carries the session which is passed to org.springframework.web.context.request.DestructionCallbackBindingListener.valueUnbound(HttpSessionBindingEvent) Then, referencing session scoped dependencies should still be possible.

    Spring JIRA | 4 years ago | Sebastian Paul
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.localizationManagerImpl': Scope 'session' is not active for the current thread; ... In my concrete case, applicationManagerImpl tries to remove an event listener from localizationManagerImpl. Of course, he only knows about the interface, so he is not aware of the fact that localizationManagerImpl is also session scoped (deregistration of listener is not really necessary). The problem is caused by the missing HttpServletRequest, which usually carries the session. When sessions expire, no request is active, so the RequestContextHolder has no RequestAttributes
  2. 0

    Destroy method of session scoped bean cannot access other session scoped bean: CommonAnnotationBeanPostProcessor - postProcessBeforeDestruction - Invocation of destroy method failed on bean with name 'scopedTarget.applicationManagerImpl': org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.localizationManagerImpl': Scope 'session' is not active for the current thread; ... In my concrete case, applicationManagerImpl tries to remove an event listener from localizationManagerImpl. Of course, he only knows about the interface, so he is not aware of the fact that localizationManagerImpl is also session scoped (deregistration of listener is not really necessary). The problem is caused by the missing HttpServletRequest, which usually carries the session. When sessions expire, no request is active, so the RequestContextHolder has no RequestAttributes at org.springframework.web.context.request.DestructionCallbackBindingListener.valueUnbound(DestructionCallbackBindingListener.java:51) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE] at org.apache.catalina.session.StandardSession.removeAttributeInternal(StandardSession.java:1710) [catalina.jar:6.0.35.B] at org.apache.catalina.session.StandardSession.expire(StandardSession.java:812) [catalina.jar:6.0.35.B] at org.apache.catalina.session.StandardSession.isValid(StandardSession.java:587) [catalina.jar:6.0.35.B] at org.apache.catalina.session.ManagerBase.processExpires(ManagerBase.java:714) [catalina.jar:6.0.35.B] at org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:699) [catalina.jar:6.0.35.B] at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1368) [catalina.jar:6.0.35.B] at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1653) [catalina.jar:6.0.35.B] at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1662) [catalina.jar:6.0.35.B] at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1662) [catalina.jar:6.0.35.B] at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1642) [catalina.jar:6.0.35.B] Spring should handle this by setting up a RequestAttributes instance which carries the session which is passed to org.springframework.web.context.request.DestructionCallbackBindingListener.valueUnbound(HttpSessionBindingEvent) Then, referencing session scoped dependencies should still be possible.

    Spring JIRA | 4 years ago | Sebastian Paul
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.localizationManagerImpl': Scope 'session' is not active for the current thread; ... In my concrete case, applicationManagerImpl tries to remove an event listener from localizationManagerImpl. Of course, he only knows about the interface, so he is not aware of the fact that localizationManagerImpl is also session scoped (deregistration of listener is not really necessary). The problem is caused by the missing HttpServletRequest, which usually carries the session. When sessions expire, no request is active, so the RequestContextHolder has no RequestAttributes
  3. 0
    You don't have an active HTTP session when the bean is requested.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0
    Add slf4j dependency to your pom.xml
  6. 0
    Spring expects that the EntityManagerFactory has to be called "entityManagerFactory". It uses convention over configuration to make it easier to use.

    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.springframework.beans.factory.BeanCreationException

      Error creating bean with name 'scopedTarget.localizationManagerImpl': Scope 'session' is not active for the current thread; ... In my concrete case, applicationManagerImpl tries to remove an event listener from localizationManagerImpl. Of course, he only knows about the interface, so he is not aware of the fact that localizationManagerImpl is also session scoped (deregistration of listener is not really necessary). The problem is caused by the missing HttpServletRequest, which usually carries the session. When sessions expire, no request is active, so the RequestContextHolder has no RequestAttributes

      at org.springframework.web.context.request.DestructionCallbackBindingListener.valueUnbound()
    2. Spring
      DestructionCallbackBindingListener.valueUnbound
      1. org.springframework.web.context.request.DestructionCallbackBindingListener.valueUnbound(DestructionCallbackBindingListener.java:51)[spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
      1 frame
    3. Glassfish Core
      ContainerBase$ContainerBackgroundProcessor.run
      1. org.apache.catalina.session.StandardSession.removeAttributeInternal(StandardSession.java:1710)[catalina.jar:6.0.35.B]
      2. org.apache.catalina.session.StandardSession.expire(StandardSession.java:812)[catalina.jar:6.0.35.B]
      3. org.apache.catalina.session.StandardSession.isValid(StandardSession.java:587)[catalina.jar:6.0.35.B]
      4. org.apache.catalina.session.ManagerBase.processExpires(ManagerBase.java:714)[catalina.jar:6.0.35.B]
      5. org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:699)[catalina.jar:6.0.35.B]
      6. org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1368)[catalina.jar:6.0.35.B]
      7. org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1653)[catalina.jar:6.0.35.B]
      8. org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1662)[catalina.jar:6.0.35.B]
      9. org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1662)[catalina.jar:6.0.35.B]
      10. org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1642)[catalina.jar:6.0.35.B]
      10 frames