4 Replies Latest reply on Apr 14, 2015 2:13 AM by Jozef Hartinger

    using @Produces and @Inject across AS7 module dependencies

    Ralf Sigmund Newbie



      is it possible to use a CDI producer method defined in module A in order to CDI inject into a bean in a second module B?


      Is there any description on the relation between CDI and the JBoss Modules System?


      In producer.jar:



      import javax.enterprise.inject.Produces;

      import javax.enterprise.inject.spi.InjectionPoint;

      import java.util.logging.Logger;


      public class Producer {



          public static Logger produceLog(InjectionPoint injectionPoint) {

              return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());




      In consumer.war:


      import javax.inject.Inject;

      import java.util.logging.Logger;



      public class Consumer {


          Logger logger;


          public void doLog() {

              logger.info("Hello CDI with JBoss Modules");






      module B has a Manifest Dependency on module A:


      Manifest-Version: 1.0

      Dependencies: deployment.producer.jar



      this approach leads to an weld unsatisfied dependency problem:


      "JBAS014671: Failed services" => {"jboss.deployment.unit.\"consumer.war\".WeldService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"consumer.war\".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Logger] with qualifiers [@Default] at injection point [[field] @Inject question.Consumer.logger]"




      I posted a sample project on Github: https://github.com/sistar/jboss-cdi-demo