CDI injection of managed bean from java module
woelfle Jul 27, 2012 6:01 AMWe have an JEE 6 enterprise application running in a JBoss 7.2.0 Alpha1 container with following structure:
app.ear
services.jar (EJB Module)
beans.xml
ServiceA.java
lib/domain.jar (Java module)
beans.xml
SomeDomainLogic.java
ServiceA contains a field of type 'SomeDomainLogic'. This field should be injected by CDI. Therefore there is a @Inject annotation at the field. When starting up the container it fails with following exception:
10:21:37,374 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.subunit."app.ear"."services.jar".component.ServiceA.WeldInstantiator: org.jboss.msc.service.StartException in service jboss.deployment.subunit."app.ear"."services.jar".component.ServiceA.WeldInstantiator: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0]
Caused by: java.lang.RuntimeException: JBAS016060: Could not resolve CDI bean for injection point private SomeDomainLogic ServiceA.logic with qualifiers []
at org.jboss.as.weld.injection.WeldEEInjection.createWeldEEInjection(WeldEEInjection.java:161)
at org.jboss.as.weld.injection.WeldManagedReferenceFactory.start(WeldManagedReferenceFactory.java:117)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
... 3 more
If the class is moved into the 'services.jar' EJB Module everything works fine. But when it resides in the 'domain.jar' Java module it is not found. Has anyone an idea what we are doing wrong? Or is this a bug?