2 Replies Latest reply on Jul 21, 2010 9:11 AM by pmuir

    Correct way to inject BeanManager into portable extension?

    ljnelson

      Hello.  I am attempting to write a portable extension.  I have it so that the container (Glassfish 3.1b09) identifies my extension and loads it properly.  However, I cannot seem to inject a BeanManager into my extension for programmatic use.


      I have tried this:


      @Inject
      private BeanManager beanManager;




      ...and this:


      @Inject
      public void afterDeploymentValidation(@Observes AfterDeploymentValidation event, BeanManager beanManager) {
        //...
      }



      ...but neither worked.  In the first case, the BeanManager is simply not injected.  In the second case, I get the following exception on deployment:


      WELD-000408 org.jboss.weld.event-ObserverMethod-com.foobar.MyPortableExtension.method afterDeploymentValidation(javax.enterprise.inject.spi.AfterDeploymentValidation, javax.enterprise.inject.spi.BeanManager) cannot be annotated with @Initializer



      Is this pilot error or a bug in Glassfish's Weld integration?


      Thanks,


      Laird