1 Reply Latest reply on Mar 7, 2012 2:33 AM by Jozef Hartinger

    Producer in via extension registered beans not found

    Daniel Straub Newbie

      I add  a bean in a CDI Extension during the deployment with custom subsystem (in the same way as answered by Ales in https://community.jboss.org/message/71529  - but before i read this thread )

      Everything works fine, the bean is injected in all requiered places.


      But as next I add some @Produces (more precisely, I create a bean with javassit with @Produces annoted methods).

      This new producers are not recogniced by Weld (WELD-001408 Unsatisfied dependencies ... we love this message ).


      I assume the new beans, added in the extension at afterBeanDiscovery - are only used for injection and not scanned for anntoations.

      We can change existing producesrs in processProducer (is called before afterBeanDiscovery), but is there a way to add dynamically new producers ?

        • 1. Re: Producer in via extension registered beans not found
          Jozef Hartinger Master

          If you want to add a class that would not be normally scanned, do that using BeforeBeanDiscovery.addAnnotatedType(). The class will be scanned for metadata as you would expect (including producer methods).


          You can also use AfterBeanDiscovery.addBean() to register beans directly. In that case you need to provide an implementation of the Bean interface that represents the producer method (you'll have to implement the create() and destroy() methods to lookup the hosting bean a invoke a method).