java.lang.RuntimeException: No Session found for current thread

Atlassian JIRA | Diego Berrueta | 3 years ago
  1. 0

    h2. Steps to reproduce # Setup Crowd and switch to in-memory token storage. # Shutdown Crowd and restart the server again h2. Expected behaviour After restart, Crowd should be using in-memory token storage. h2. Observed behaviour On restart, Crowd produces an exception in the logs: {noformat} 2013-09-13 09:04:20,402 localhost-startStop-1 INFO [crowd.manager.token.SwitchableTokenManagerImpl] About to switch to in-memory token storage 2013-09-13 09:04:20,403 localhost-startStop-1 ERROR [atlassian.event.internal.AsynchronousAbleEventDispatcher] There was an exception thrown trying to dispatch event 'com.atlassian.config.lifecycle.events.ApplicationStartedEvent@11d5e909' from the invoker 'SingleParameterMethodListenerInvoker{method=public void com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl.onApplicationStartedEvent(com.atlassian.config.lifecycle.events.ApplicationStartedEvent), listener=com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl@60dd42c1}'. java.lang.RuntimeException: No Session found for current thread at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:54) at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$2.run(AsynchronousAbleEventDispatcher.java:66) at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1.execute(AsynchronousAbleEventDispatcher.java:32) at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:60) at com.atlassian.event.internal.EventPublisherImpl.invokeListeners(EventPublisherImpl.java:160) at com.atlassian.event.internal.EventPublisherImpl.publish(EventPublisherImpl.java:79) at com.atlassian.crowd.console.listener.StartupListener.contextInitialized(StartupListener.java:106) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1636) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) Caused by: org.hibernate.HibernateException: No Session found for current thread at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:97) at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:988) at com.atlassian.crowd.util.persistence.hibernate.HibernateDao.session(HibernateDao.java:183) at com.atlassian.crowd.dao.token.TokenDAOHibernate.loadAll(TokenDAOHibernate.java:93) at com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl.move(SwitchableTokenManagerImpl.java:386) at com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl.switchToMemory(SwitchableTokenManagerImpl.java:337) at com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl.setUsingDatabaseStorage(SwitchableTokenManagerImpl.java:316) at com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl.updateTokenStorage(SwitchableTokenManagerImpl.java:419) at com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl.onApplicationStartedEvent(SwitchableTokenManagerImpl.java:406) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:36) ... 20 more {noformat} Moreover, although the configuration screen shows that Crowd is using in-memory token storage, that's not true. It is actually using database storage. This can be demonstrated by deleting the contents of the cwd_token table in the database, which causes all sessions to be lost.

    Atlassian JIRA | 3 years ago | Diego Berrueta Munoz
    java.lang.RuntimeException: No Session found for current thread
  2. 0

    h2. Steps to reproduce # Setup Crowd and switch to in-memory token storage. # Shutdown Crowd and restart the server again h2. Expected behaviour After restart, Crowd should be using in-memory token storage. h2. Observed behaviour On restart, Crowd produces an exception in the logs: {noformat} 2013-09-13 09:04:20,402 localhost-startStop-1 INFO [crowd.manager.token.SwitchableTokenManagerImpl] About to switch to in-memory token storage 2013-09-13 09:04:20,403 localhost-startStop-1 ERROR [atlassian.event.internal.AsynchronousAbleEventDispatcher] There was an exception thrown trying to dispatch event 'com.atlassian.config.lifecycle.events.ApplicationStartedEvent@11d5e909' from the invoker 'SingleParameterMethodListenerInvoker{method=public void com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl.onApplicationStartedEvent(com.atlassian.config.lifecycle.events.ApplicationStartedEvent), listener=com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl@60dd42c1}'. java.lang.RuntimeException: No Session found for current thread at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:54) at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$2.run(AsynchronousAbleEventDispatcher.java:66) at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1.execute(AsynchronousAbleEventDispatcher.java:32) at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:60) at com.atlassian.event.internal.EventPublisherImpl.invokeListeners(EventPublisherImpl.java:160) at com.atlassian.event.internal.EventPublisherImpl.publish(EventPublisherImpl.java:79) at com.atlassian.crowd.console.listener.StartupListener.contextInitialized(StartupListener.java:106) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1636) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) Caused by: org.hibernate.HibernateException: No Session found for current thread at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:97) at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:988) at com.atlassian.crowd.util.persistence.hibernate.HibernateDao.session(HibernateDao.java:183) at com.atlassian.crowd.dao.token.TokenDAOHibernate.loadAll(TokenDAOHibernate.java:93) at com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl.move(SwitchableTokenManagerImpl.java:386) at com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl.switchToMemory(SwitchableTokenManagerImpl.java:337) at com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl.setUsingDatabaseStorage(SwitchableTokenManagerImpl.java:316) at com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl.updateTokenStorage(SwitchableTokenManagerImpl.java:419) at com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl.onApplicationStartedEvent(SwitchableTokenManagerImpl.java:406) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:36) ... 20 more {noformat} Moreover, although the configuration screen shows that Crowd is using in-memory token storage, that's not true. It is actually using database storage. This can be demonstrated by deleting the contents of the cwd_token table in the database, which causes all sessions to be lost.

    Atlassian JIRA | 3 years ago | Diego Berrueta
    java.lang.RuntimeException: No Session found for current thread
  3. 0

    Spring + Hibernate: No session found in @Transactional method

    Stack Overflow | 3 years ago | V_B
    org.hibernate.HibernateException: No Session found for current thread
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Spring 3 + Hibernate 4, No session for the current thread, Tried Everything

    Stack Overflow | 3 years ago | HeadBangingSloth
    org.hibernate.HibernateException: No Session found for current thread
  6. 0

    No Session found for current thread hibernate transactions by aop xml style

    Stack Overflow | 3 years ago | i'm a user
    org.hibernate.HibernateException: No Session found for current thread

    21 unregistered visitors
    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.HibernateException

      No Session found for current thread

      at org.springframework.orm.hibernate4.SpringSessionContext.currentSession()
    2. Spring ORM
      SpringSessionContext.currentSession
      1. org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:97)
      1 frame
    3. Hibernate
      SessionFactoryImpl.getCurrentSession
      1. org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:988)
      1 frame
    4. com.atlassian.crowd
      SwitchableTokenManagerImpl.onApplicationStartedEvent
      1. com.atlassian.crowd.util.persistence.hibernate.HibernateDao.session(HibernateDao.java:183)
      2. com.atlassian.crowd.dao.token.TokenDAOHibernate.loadAll(TokenDAOHibernate.java:93)
      3. com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl.move(SwitchableTokenManagerImpl.java:386)
      4. com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl.switchToMemory(SwitchableTokenManagerImpl.java:337)
      5. com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl.setUsingDatabaseStorage(SwitchableTokenManagerImpl.java:316)
      6. com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl.updateTokenStorage(SwitchableTokenManagerImpl.java:419)
      7. com.atlassian.crowd.manager.token.SwitchableTokenManagerImpl.onApplicationStartedEvent(SwitchableTokenManagerImpl.java:406)
      7 frames
    5. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:601)
      4 frames
    6. com.atlassian.event
      EventPublisherImpl.publish
      1. com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:36)
      2. com.atlassian.event.internal.AsynchronousAbleEventDispatcher$2.run(AsynchronousAbleEventDispatcher.java:66)
      3. com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1.execute(AsynchronousAbleEventDispatcher.java:32)
      4. com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:60)
      5. com.atlassian.event.internal.EventPublisherImpl.invokeListeners(EventPublisherImpl.java:160)
      6. com.atlassian.event.internal.EventPublisherImpl.publish(EventPublisherImpl.java:79)
      6 frames
    7. com.atlassian.crowd
      StartupListener.contextInitialized
      1. com.atlassian.crowd.console.listener.StartupListener.contextInitialized(StartupListener.java:106)
      1 frame
    8. Glassfish Core
      HostConfig$DeployDescriptor.run
      1. org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
      2. org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
      3. org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      4. org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
      5. org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
      6. org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
      7. org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657)
      8. org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1636)
      8 frames
    9. Java RT
      Thread.run
      1. java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
      2. java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
      3. java.util.concurrent.FutureTask.run(FutureTask.java:166)
      4. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      5. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      6. java.lang.Thread.run(Thread.java:722)
      6 frames