Singleton is not set exception for extension observer of BeforeShutdown event
-----------------------------------------------------------------------------

                 Key: WELD-891
                 URL: https://issues.jboss.org/browse/WELD-891
             Project: Weld
          Issue Type: Bug
          Components: Events
    Affects Versions: 1.1.1.Final
         Environment: Weld SE
            Reporter: Aaron Anderson
         Attachments: weldext.zip

When updating to Weld 1.1.1.Final from Weld 1.1.0.Final (this version works 
fine) the following exception is thrown during a Weld shutdown() invocation:


225509 [main] ERROR org.jboss.weld.Bootstrap - Exception(s) thrown during observ
er of BeforeShutdown
225509 [main] ERROR org.jboss.weld.Bootstrap -
java.lang.IllegalStateException: Singleton is not set
        at org.jboss.weld.bootstrap.api.helpers.IsolatedStaticSingletonProvider$
IsolatedStaticSingleton.get(IsolatedStaticSingletonProvider.java:52)
        at org.jboss.weld.context.AbstractSharedContext.getBeanStore(AbstractSha
redContext.java:54)
        at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:93)
        at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.j
ava:690)
        at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.
java:264)
        at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.jav
a:234)
        at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractC
ontainerEvent.java:88)
        at org.jboss.weld.bootstrap.events.BeforeShutdownImpl.fire(BeforeShutdow
nImpl.java:62)
        at org.jboss.weld.bootstrap.events.BeforeShutdownImpl.fire(BeforeShutdow
nImpl.java:50)
        at org.jboss.weld.bootstrap.WeldBootstrap.shutdown(WeldBootstrap.java:49
1)
        at org.jboss.weld.environment.se.ShutdownManager.shutdown(ShutdownManage
r.java:45)
        at org.jboss.weld.environment.se.org$jboss$weld$bean-classpath-ManagedBe
an-org$jboss$weld$environment$se$ShutdownManager$@javax$enterprise$context$Appli
cationScoped()${}_$$_WeldClientProxy.shutdown(org$jboss$weld$bean-classpath-Mana
gedBean-org$jboss$weld$environment$se$ShutdownManager$@javax$enterprise$context$
ApplicationScoped()${}_$$_WeldClientProxy.java)
        at org.jboss.weld.environment.se.Weld.shutdown(Weld.java:169)
        at org.apache.ode.server.event.EventTest.tearDownAfterClass(EventTest.ja
va:76)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(Framework
Method.java:44)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCal
lable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMe
thod.java:41)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.ja
va:37)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
        at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.
java:35)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4
Provider.java:146)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider
.java:97)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.inv
oke(ProviderFactory.java:103)
        at $Proxy0.invoke(Unknown Source)
        at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(Suref
ireStarter.java:145)
        at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(S
urefireStarter.java:87)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:
69)



Running the code through a debugger it looks like my CDI extension, which is 
not annotated with a scope annotation, is being placed in the ApplicationScope 
context but when Weld shutdowns the following code is invoked

WeldBootstrap line 490:

            try
            {
               applicationContext.invalidate();
               BeforeShutdownImpl.fire(deploymentManager, beanDeployments);
            }

which invalidates the context the extension exists in before invoking the 
shutdown event on the extension thus causing the exception.

Please download and run the attached maven example by running mvn clean test

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
weld-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/weld-issues

Reply via email to