1 Reply Latest reply on Nov 4, 2016 7:39 PM by ljnelson

    Should CDI.current() work in code called by a portable extension?

    ljnelson

      Admittedly I am deep in the weeds here.  This is with Weld SE 3.0.0.Alpha17.

       

      I am writing a portable extension that is reacting to the AfterDeploymentValidation event.  This means the container, so far, is almost open for business.

       

      Some other code that I'm integrating with is (eventually) calling CDI.current().getBeanManager().  The current() call is failing (throws an IllegalStateException).

       

      Specifically, WeldContainer#getRunningContainerIds() is returning an empty set at this point, which causes the CDI#current() call to fail.

       

      Is this a bug?  I would think so since the specification says:

       

      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.

       

      Thanks,

      Best,

      Laird