java.lang.IllegalStateException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • I raised http://jira.springframework.org/browse/SPR-5345, but it looks like this is a bug in Spring-DM, or at least a hole between the two projects. Spring prevents close() from being run while refresh() is active. It can do this by sychronizing both methids. Spring-DM on the other hand splits refresh into startRefresh()/completeRefresh() with a sync lock around both methods. The problem is that the mulitcast is initialized in the second phase, so something can call close() after startRefresh() has completed and get an error from the multicaster. Not quite sure what the correct solution is here. Original bug follows. In AbstractApplicationContext the isActive flag is set in prepareRefresh(), however the multicaster is not initialized until later in refresh(), thus if you have error handling code which does: if (context.isActive()) { context.close(); } you end up with this error: <09-Dec-2008 11:00:32 o'clock GMT> <Error> <org.springframework.osgi.context.sup port.OsgiBundleXmlApplicationContext> <BEA-000000> <Exception thrown from Applic ationListener handling ContextClosedEvent java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - c all 'refresh' before multicasting events via the context: org.springframework.os gi.context.support.OsgiBundleXmlApplicationContext@9d4d84: display name [OsgiBun dleXmlApplicationContext(bundle=helloworld, config=osgibundle:/META-INF/spring/* .xml)]; startup date [Tue Dec 09 11:00:31 GMT 2008]; root of context hierarchy at org.springframework.context.support.AbstractApplicationContext.getApp licationEventMulticaster(AbstractApplicationContext.java:287) at org.springframework.context.support.AbstractApplicationContext.publis hEvent(AbstractApplicationContext.java:274) at org.springframework.context.support.AbstractApplicationContext.doClos e(AbstractApplicationContext.java:819) at org.springframework.osgi.context.support.AbstractOsgiBundleApplicatio nContext.doClose(AbstractOsgiBundleApplicationContext.java:206) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.access$501(AbstractDelegatedExecutionApplicationContext.java:68 ) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext$2.run(AbstractDelegatedExecutionApplicationContext.java:217) at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCus tomTCCL(PrivilegedUtils.java:85) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.normalClose(AbstractDelegatedExecutionApplicationContext.java:2 13) at org.springframework.osgi.extender.internal.dependencies.startup.Depen dencyWaiterApplicationContextExecutor.close(DependencyWaiterApplicationContextEx ecutor.java:345) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.doClose(AbstractDelegatedExecutionApplicationContext.java:228) at org.springframework.context.support.AbstractApplicationContext.close( AbstractApplicationContext.java:794) at org.springframework.osgi.extender.internal.activator.ContextLoaderLis tener$3.run(ContextLoaderListener.java:832) at org.springframework.osgi.extender.internal.util.concurrent.RunnableTi medExecution$MonitoredRunnable.run(RunnableTimedExecution.java:60) at org.springframework.scheduling.timer.DelegatingTimerTask.run(Delegati ngTimerTask.java:66) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462) Spring-DM has exactly this kind of code and fails in exactly this way. Either the event should be silently dropped or isActive should be set at the end of refresh()
    via by Andy Piper,
  • In AbstractApplicationContext the isActive flag is set in prepareRefresh(), however the multicaster is not initialized until later in refresh(), thus if you have error handling code which does: if (context.isActive()) { context.close(); } you end up with this error: <09-Dec-2008 11:00:32 o'clock GMT> <Error> <org.springframework.osgi.context.sup port.OsgiBundleXmlApplicationContext> <BEA-000000> <Exception thrown from Applic ationListener handling ContextClosedEvent java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - c all 'refresh' before multicasting events via the context: org.springframework.os gi.context.support.OsgiBundleXmlApplicationContext@9d4d84: display name [OsgiBun dleXmlApplicationContext(bundle=helloworld, config=osgibundle:/META-INF/spring/* .xml)]; startup date [Tue Dec 09 11:00:31 GMT 2008]; root of context hierarchy at org.springframework.context.support.AbstractApplicationContext.getApp licationEventMulticaster(AbstractApplicationContext.java:287) at org.springframework.context.support.AbstractApplicationContext.publis hEvent(AbstractApplicationContext.java:274) at org.springframework.context.support.AbstractApplicationContext.doClos e(AbstractApplicationContext.java:819) at org.springframework.osgi.context.support.AbstractOsgiBundleApplicatio nContext.doClose(AbstractOsgiBundleApplicationContext.java:206) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.access$501(AbstractDelegatedExecutionApplicationContext.java:68 ) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext$2.run(AbstractDelegatedExecutionApplicationContext.java:217) at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCus tomTCCL(PrivilegedUtils.java:85) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.normalClose(AbstractDelegatedExecutionApplicationContext.java:2 13) at org.springframework.osgi.extender.internal.dependencies.startup.Depen dencyWaiterApplicationContextExecutor.close(DependencyWaiterApplicationContextEx ecutor.java:345) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.doClose(AbstractDelegatedExecutionApplicationContext.java:228) at org.springframework.context.support.AbstractApplicationContext.close( AbstractApplicationContext.java:794) at org.springframework.osgi.extender.internal.activator.ContextLoaderLis tener$3.run(ContextLoaderListener.java:832) at org.springframework.osgi.extender.internal.util.concurrent.RunnableTi medExecution$MonitoredRunnable.run(RunnableTimedExecution.java:60) at org.springframework.scheduling.timer.DelegatingTimerTask.run(Delegati ngTimerTask.java:66) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462) Spring-DM has exactly this kind of code and fails in exactly this way. Either the event should be silently dropped or isActive should be set at the end of refresh()
    via by Andy Piper,
  • In AbstractApplicationContext the isActive flag is set in prepareRefresh(), however the multicaster is not initialized until later in refresh(), thus if you have error handling code which does: if (context.isActive()) { context.close(); } you end up with this error: <09-Dec-2008 11:00:32 o'clock GMT> <Error> <org.springframework.osgi.context.sup port.OsgiBundleXmlApplicationContext> <BEA-000000> <Exception thrown from Applic ationListener handling ContextClosedEvent java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - c all 'refresh' before multicasting events via the context: org.springframework.os gi.context.support.OsgiBundleXmlApplicationContext@9d4d84: display name [OsgiBun dleXmlApplicationContext(bundle=helloworld, config=osgibundle:/META-INF/spring/* .xml)]; startup date [Tue Dec 09 11:00:31 GMT 2008]; root of context hierarchy at org.springframework.context.support.AbstractApplicationContext.getApp licationEventMulticaster(AbstractApplicationContext.java:287) at org.springframework.context.support.AbstractApplicationContext.publis hEvent(AbstractApplicationContext.java:274) at org.springframework.context.support.AbstractApplicationContext.doClos e(AbstractApplicationContext.java:819) at org.springframework.osgi.context.support.AbstractOsgiBundleApplicatio nContext.doClose(AbstractOsgiBundleApplicationContext.java:206) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.access$501(AbstractDelegatedExecutionApplicationContext.java:68 ) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext$2.run(AbstractDelegatedExecutionApplicationContext.java:217) at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCus tomTCCL(PrivilegedUtils.java:85) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.normalClose(AbstractDelegatedExecutionApplicationContext.java:2 13) at org.springframework.osgi.extender.internal.dependencies.startup.Depen dencyWaiterApplicationContextExecutor.close(DependencyWaiterApplicationContextEx ecutor.java:345) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.doClose(AbstractDelegatedExecutionApplicationContext.java:228) at org.springframework.context.support.AbstractApplicationContext.close( AbstractApplicationContext.java:794) at org.springframework.osgi.extender.internal.activator.ContextLoaderLis tener$3.run(ContextLoaderListener.java:832) at org.springframework.osgi.extender.internal.util.concurrent.RunnableTi medExecution$MonitoredRunnable.run(RunnableTimedExecution.java:60) at org.springframework.scheduling.timer.DelegatingTimerTask.run(Delegati ngTimerTask.java:66) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462) Spring-DM has exactly this kind of code and fails in exactly this way. Either the event should be silently dropped or isActive should be set at the end of refresh()
    via by Andy Piper,
  • I raised http://jira.springframework.org/browse/SPR-5345, but it looks like this is a bug in Spring-DM, or at least a hole between the two projects. Spring prevents close() from being run while refresh() is active. It can do this by sychronizing both methids. Spring-DM on the other hand splits refresh into startRefresh()/completeRefresh() with a sync lock around both methods. The problem is that the mulitcast is initialized in the second phase, so something can call close() after startRefresh() has completed and get an error from the multicaster. Not quite sure what the correct solution is here. Original bug follows. In AbstractApplicationContext the isActive flag is set in prepareRefresh(), however the multicaster is not initialized until later in refresh(), thus if you have error handling code which does: if (context.isActive()) { context.close(); } you end up with this error: <09-Dec-2008 11:00:32 o'clock GMT> <Error> <org.springframework.osgi.context.sup port.OsgiBundleXmlApplicationContext> <BEA-000000> <Exception thrown from Applic ationListener handling ContextClosedEvent java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - c all 'refresh' before multicasting events via the context: org.springframework.os gi.context.support.OsgiBundleXmlApplicationContext@9d4d84: display name [OsgiBun dleXmlApplicationContext(bundle=helloworld, config=osgibundle:/META-INF/spring/* .xml)]; startup date [Tue Dec 09 11:00:31 GMT 2008]; root of context hierarchy at org.springframework.context.support.AbstractApplicationContext.getApp licationEventMulticaster(AbstractApplicationContext.java:287) at org.springframework.context.support.AbstractApplicationContext.publis hEvent(AbstractApplicationContext.java:274) at org.springframework.context.support.AbstractApplicationContext.doClos e(AbstractApplicationContext.java:819) at org.springframework.osgi.context.support.AbstractOsgiBundleApplicatio nContext.doClose(AbstractOsgiBundleApplicationContext.java:206) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.access$501(AbstractDelegatedExecutionApplicationContext.java:68 ) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext$2.run(AbstractDelegatedExecutionApplicationContext.java:217) at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCus tomTCCL(PrivilegedUtils.java:85) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.normalClose(AbstractDelegatedExecutionApplicationContext.java:2 13) at org.springframework.osgi.extender.internal.dependencies.startup.Depen dencyWaiterApplicationContextExecutor.close(DependencyWaiterApplicationContextEx ecutor.java:345) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.doClose(AbstractDelegatedExecutionApplicationContext.java:228) at org.springframework.context.support.AbstractApplicationContext.close( AbstractApplicationContext.java:794) at org.springframework.osgi.extender.internal.activator.ContextLoaderLis tener$3.run(ContextLoaderListener.java:832) at org.springframework.osgi.extender.internal.util.concurrent.RunnableTi medExecution$MonitoredRunnable.run(RunnableTimedExecution.java:60) at org.springframework.scheduling.timer.DelegatingTimerTask.run(Delegati ngTimerTask.java:66) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462) Spring-DM has exactly this kind of code and fails in exactly this way. Either the event should be silently dropped or isActive should be set at the end of refresh()
    via by Andy Piper,
  • In AbstractApplicationContext the isActive flag is set in prepareRefresh(), however the multicaster is not initialized until later in refresh(), thus if you have error handling code which does: if (context.isActive()) { context.close(); } you end up with this error: <09-Dec-2008 11:00:32 o'clock GMT> <Error> <org.springframework.osgi.context.sup port.OsgiBundleXmlApplicationContext> <BEA-000000> <Exception thrown from Applic ationListener handling ContextClosedEvent java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - c all 'refresh' before multicasting events via the context: org.springframework.os gi.context.support.OsgiBundleXmlApplicationContext@9d4d84: display name [OsgiBun dleXmlApplicationContext(bundle=helloworld, config=osgibundle:/META-INF/spring/* .xml)]; startup date [Tue Dec 09 11:00:31 GMT 2008]; root of context hierarchy at org.springframework.context.support.AbstractApplicationContext.getApp licationEventMulticaster(AbstractApplicationContext.java:287) at org.springframework.context.support.AbstractApplicationContext.publis hEvent(AbstractApplicationContext.java:274) at org.springframework.context.support.AbstractApplicationContext.doClos e(AbstractApplicationContext.java:819) at org.springframework.osgi.context.support.AbstractOsgiBundleApplicatio nContext.doClose(AbstractOsgiBundleApplicationContext.java:206) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.access$501(AbstractDelegatedExecutionApplicationContext.java:68 ) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext$2.run(AbstractDelegatedExecutionApplicationContext.java:217) at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCus tomTCCL(PrivilegedUtils.java:85) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.normalClose(AbstractDelegatedExecutionApplicationContext.java:2 13) at org.springframework.osgi.extender.internal.dependencies.startup.Depen dencyWaiterApplicationContextExecutor.close(DependencyWaiterApplicationContextEx ecutor.java:345) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.doClose(AbstractDelegatedExecutionApplicationContext.java:228) at org.springframework.context.support.AbstractApplicationContext.close( AbstractApplicationContext.java:794) at org.springframework.osgi.extender.internal.activator.ContextLoaderLis tener$3.run(ContextLoaderListener.java:832) at org.springframework.osgi.extender.internal.util.concurrent.RunnableTi medExecution$MonitoredRunnable.run(RunnableTimedExecution.java:60) at org.springframework.scheduling.timer.DelegatingTimerTask.run(Delegati ngTimerTask.java:66) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462) Spring-DM has exactly this kind of code and fails in exactly this way. Either the event should be silently dropped or isActive should be set at the end of refresh()
    via by Andy Piper,
  • In AbstractApplicationContext the isActive flag is set in prepareRefresh(), however the multicaster is not initialized until later in refresh(), thus if you have error handling code which does: if (context.isActive()) { context.close(); } you end up with this error: <09-Dec-2008 11:00:32 o'clock GMT> <Error> <org.springframework.osgi.context.sup port.OsgiBundleXmlApplicationContext> <BEA-000000> <Exception thrown from Applic ationListener handling ContextClosedEvent java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - c all 'refresh' before multicasting events via the context: org.springframework.os gi.context.support.OsgiBundleXmlApplicationContext@9d4d84: display name [OsgiBun dleXmlApplicationContext(bundle=helloworld, config=osgibundle:/META-INF/spring/* .xml)]; startup date [Tue Dec 09 11:00:31 GMT 2008]; root of context hierarchy at org.springframework.context.support.AbstractApplicationContext.getApp licationEventMulticaster(AbstractApplicationContext.java:287) at org.springframework.context.support.AbstractApplicationContext.publis hEvent(AbstractApplicationContext.java:274) at org.springframework.context.support.AbstractApplicationContext.doClos e(AbstractApplicationContext.java:819) at org.springframework.osgi.context.support.AbstractOsgiBundleApplicatio nContext.doClose(AbstractOsgiBundleApplicationContext.java:206) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.access$501(AbstractDelegatedExecutionApplicationContext.java:68 ) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext$2.run(AbstractDelegatedExecutionApplicationContext.java:217) at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCus tomTCCL(PrivilegedUtils.java:85) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.normalClose(AbstractDelegatedExecutionApplicationContext.java:2 13) at org.springframework.osgi.extender.internal.dependencies.startup.Depen dencyWaiterApplicationContextExecutor.close(DependencyWaiterApplicationContextEx ecutor.java:345) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.doClose(AbstractDelegatedExecutionApplicationContext.java:228) at org.springframework.context.support.AbstractApplicationContext.close( AbstractApplicationContext.java:794) at org.springframework.osgi.extender.internal.activator.ContextLoaderLis tener$3.run(ContextLoaderListener.java:832) at org.springframework.osgi.extender.internal.util.concurrent.RunnableTi medExecution$MonitoredRunnable.run(RunnableTimedExecution.java:60) at org.springframework.scheduling.timer.DelegatingTimerTask.run(Delegati ngTimerTask.java:66) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462) Spring-DM has exactly this kind of code and fails in exactly this way. Either the event should be silently dropped or isActive should be set at the end of refresh()
    via by Andy Piper,
    • java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - c all 'refresh' before multicasting events via the context: org.springframework.os gi.context.support.OsgiBundleXmlApplicationContext@9d4d84: display name [OsgiBun dleXmlApplicationContext(bundle=helloworld, config=osgibundle:/META-INF/spring/* .xml)]; startup date [Tue Dec 09 11:00:31 GMT 2008]; root of context hierarchy at org.springframework.context.support.AbstractApplicationContext.getApp licationEventMulticaster(AbstractApplicationContext.java:287) at org.springframework.context.support.AbstractApplicationContext.publis hEvent(AbstractApplicationContext.java:274) at org.springframework.context.support.AbstractApplicationContext.doClos e(AbstractApplicationContext.java:819) at org.springframework.osgi.context.support.AbstractOsgiBundleApplicatio nContext.doClose(AbstractOsgiBundleApplicationContext.java:206) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.access$501(AbstractDelegatedExecutionApplicationContext.java:68 ) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext$2.run(AbstractDelegatedExecutionApplicationContext.java:217) at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCus tomTCCL(PrivilegedUtils.java:85) at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp plicationContext.normalClose(AbstractDelegatedExecutionApplicationContext.java:2 13) at org.springframework.osgi.extender.internal.dependencies.startup.Depen dencyWaiterApplicationContextExecutor.close(DependencyWaiterApplicationContextEx ecutor.java:345) at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.doClose(AbstractDelegatedExecutionApplicationContext.java:228) at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:794) at org.springframework.osgi.extender.internal.activator.ContextLoaderListener$3.run(ContextLoaderListener.java:832) at org.springframework.osgi.extender.internal.util.concurrent.RunnableTimedExecution$MonitoredRunnable.run(RunnableTimedExecution.java:60) at org.springframework.scheduling.timer.DelegatingTimerTask.run(DelegatingTimerTask.java:66) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462)
    No Bugmate found.