14 Replies Latest reply on Mar 26, 2012 6:42 AM by alesj

    @Inject a managed bean from a JBoss module

    paul.robinson

      Hello,

       

      I have a managed bean that lives in a JBoss module. I also have a CDI application that is deployed to AS7 (recent build of master) that attempts to @Inject this managed bean. The CDI application jar specifies a dependency on my JBoss module (where the managed bean lives) in the manifest.mf. However, when I deploy my CDI application, I see the following exception:

       

       

      16:37:00,966 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."test.jar".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."test.jar".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [MyBean] with qualifiers [@Default] at injection point [[field] @Inject org.my.cdiinmodule.module.MyApp.myBean]
          at org.jboss.as.weld.services.WeldService.start(WeldService.java:96)
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_29]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_29]
          at java.lang.Thread.run(Thread.java:680) [:1.6.0_29]
      Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [MyBean] with qualifiers [@Default] at injection point [[field] @Inject org.my.cdiinmodule.module.MyApp.myBean]
          at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:274)
          at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:243)
          at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:106)
          at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:126)
          at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:345)
          at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:330)
          at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:366)
          at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:82)
          at org.jboss.as.weld.services.WeldService.start(WeldService.java:89)
          ... 5 more
      

       

      I assume this is happening because the CDI application can't find any implementations that satisfy the @Inject declaration. Which, I assume occurs because Weld is only looking in the CDI deployment for possible implementations. I've tested that the CDI application works if I move the managed bean into the same deployment archive as my CDI application.

       

      Can someone explain what I am doing wrong, or maybe point me at an example where this has been achieved?

       

      Thanks,

       

      Paul Robinson.