<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=andypiper" rel="nofollow">Andy Piper</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-5345?redirect=false" rel="nofollow">SPR-5345</a></strong> and commented</p>
<p dir="auto">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:</p>
<p dir="auto">if (context.isActive()) {<br>
context.close();<br>
}</p>
<p dir="auto">you end up with this error:</p>
<p dir="auto">&lt;09-Dec-2008 11:00:32 o'clock GMT&gt; &lt;Error&gt; &lt;org.springframework.osgi.context.sup<br>
port.OsgiBundleXmlApplicationContext&gt; &lt;BEA-000000&gt; &lt;Exception thrown from Applic<br>
ationListener handling ContextClosedEvent<br>
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - c<br>
all 'refresh' before multicasting events via the context: org.springframework.os<br>
gi.context.support.OsgiBundleXmlApplicationContext@9d4d84: display name [OsgiBun<br>
dleXmlApplicationContext(bundle=helloworld, config=osgibundle:/META-INF/spring/*<br>
.xml)]; startup date [Tue Dec 09 11:00:31 GMT 2008]; root of context hierarchy<br>
at org.springframework.context.support.AbstractApplicationContext.getApp<br>
licationEventMulticaster(AbstractApplicationContext.java:287)<br>
at org.springframework.context.support.AbstractApplicationContext.publis<br>
hEvent(AbstractApplicationContext.java:274)<br>
at org.springframework.context.support.AbstractApplicationContext.doClos<br>
e(AbstractApplicationContext.java:819)<br>
at org.springframework.osgi.context.support.AbstractOsgiBundleApplicatio<br>
nContext.doClose(AbstractOsgiBundleApplicationContext.java:206)<br>
at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp<br>
plicationContext.access$501(AbstractDelegatedExecutionApplicationContext.java:68<br>
)<br>
at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp<br>
plicationContext$2.run(AbstractDelegatedExecutionApplicationContext.java:217)<br>
at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCus<br>
tomTCCL(PrivilegedUtils.java:85)<br>
at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp<br>
plicationContext.normalClose(AbstractDelegatedExecutionApplicationContext.java:2<br>
13)<br>
at org.springframework.osgi.extender.internal.dependencies.startup.Depen<br>
dencyWaiterApplicationContextExecutor.close(DependencyWaiterApplicationContextEx<br>
ecutor.java:345)<br>
at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp<br>
plicationContext.doClose(AbstractDelegatedExecutionApplicationContext.java:228)<br>
at org.springframework.context.support.AbstractApplicationContext.close(<br>
AbstractApplicationContext.java:794)<br>
at org.springframework.osgi.extender.internal.activator.ContextLoaderLis<br>
tener$3.run(ContextLoaderListener.java:832)<br>
at org.springframework.osgi.extender.internal.util.concurrent.RunnableTi<br>
medExecution$MonitoredRunnable.run(RunnableTimedExecution.java:60)<br>
at org.springframework.scheduling.timer.DelegatingTimerTask.run(Delegati<br>
ngTimerTask.java:66)<br>
at java.util.TimerThread.mainLoop(Timer.java:512)<br>
at java.util.TimerThread.run(Timer.java:462)</p>
<p dir="auto">Spring-DM has exactly this kind of code and fails in exactly this way.</p>
<p dir="auto">Either the event should be silently dropped or isActive should be set at the end of refresh()</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.5.6</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398092302" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/10021" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/10021/hovercard" href="https://github.com/spring-projects/spring-framework/issues/10021">#10021</a> AbstractApplicationContext.isActive() out of sync with multicaster (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=rstoya05-aop" rel="nofollow">Rossen Stoyanchev</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-9384?redirect=false" rel="nofollow">SPR-9384</a></strong> and commented</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1.1</p>
<p dir="auto">This issue is a backport sub-task of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398118925" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/14010" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/14010/hovercard" href="https://github.com/spring-projects/spring-framework/issues/14010">#14010</a></p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398119038" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/14031" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/14031/hovercard" href="https://github.com/spring-projects/spring-framework/issues/14031">#14031</a> Backport "Reinstate check for a type-level <code class="notranslate">@RequestMapping</code> annotation to decide if a bean contains <code class="notranslate">@RequestMapping</code> methods" (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto"><strong>Referenced from:</strong> commits <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/2fa0e63e5ab84ac964c55a28000104d3855c886c/hovercard" href="https://github.com/spring-projects/spring-framework/commit/2fa0e63e5ab84ac964c55a28000104d3855c886c"><tt>2fa0e63</tt></a></p>