Details
-
Bug
-
Resolution: Fixed
-
Highest
-
2.7
-
None
-
None
Description
Steps to reproduce
- Setup Crowd and switch to in-memory token storage.
- Shutdown Crowd and restart the server again
Expected behaviour
After restart, Crowd should be using in-memory token storage.
Observed behaviour
On restart, Crowd produces an exception in the logs:
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
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.