-
Bug
-
Resolution: Done
-
Major
-
3.0.0.Alpha17
-
None
The specification indicates that a portable extension may acquire a BeanManager by doing:
final BeanManager beanManager = CDI.current().getBeanManager();
The relevant specification text:
A portable extension or other object may obtain a reference to the current container by calling CDI.current(). CDI.getBeanManager() may be called at any time after the container fires the BeforeBeanDiscovery container lifecycle event until the container fires the BeforeShutdown container lifecycle event.
This fails in (at least) an AfterDeploymentValidation lifecycle event observer method. I will attach a reproducer shortly.
I believe that the root cause is that the WeldContainer#RUNNING_CONTAINER_IDS collection, which backs the CDI#current() machinery, is not updated until after the container is officially placed into service. This is too late if I'm reading the specification right.