How to @Inject two similar implementations in a class?

120 views Asked by At

I have an interface with two classes implementing it. I tried to use a List to inject all the implementations in it. But I got a WELD exception.

Earlier I used javax.enterprise.inject.Instance and all implementations were injected properly.

I just wondered what if javax.enterprise.inject.Instance is not there and how can I solve my problem so I did this experiment.

Below is the stack trace

16:31:41,157 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."ejb-beginner-sessions-ear.ear".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."ejb-beginner-sessions-ear.ear".WeldStartService: Failed to start service
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1936) [jboss-msc-1.1.5.Final-redhat-1-bz-1093654.jar:1.1.5.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45]
    at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [List<StudentService>] with qualifiers [@Default] at injection point [[field] @Inject private com.ejb.beginner.sessions.web.StudentController.studentServices]
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:315)
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:284)
    at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:147)
    at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:167)
    at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:386)
    at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:371)
    at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:379)
    at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:64)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1980) [jboss-msc-1.1.5.Final-redhat-1-bz-1093654.jar:1.1.5.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1913) [jboss-msc-1.1.5.Final-redhat-1-bz-1093654.jar:1.1.5.Final]
    ... 3 more

16:31:41,189 INFO  [org.jboss.weld.deployer] (MSC service thread 1-7) JBAS016009: Stopping weld service for deployment ejb-beginner-sessions-ear.ear
16:31:41,184 ERROR [org.jboss.as.server] (HttpManagementService-threads - 1) JBAS015870: Deploy of deployment "ejb-beginner-sessions-ear.ear" was rolled back with the following failure message: 
{"JBAS014671: Failed services" => {"jboss.deployment.unit.\"ejb-beginner-sessions-ear.ear\".WeldStartService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"ejb-beginner-sessions-ear.ear\".WeldStartService: Failed to start service
    Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [List<StudentService>] with qualifiers [@Default] at injection point [[field] @Inject private com.ejb.beginner.sessions.web.StudentController.studentServices]"}}
16:31:41,215 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment null (runtime-name: ejb-beginner-sessions-impl.jar) in 31ms
16:31:41,219 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015877: Stopped deployment null (runtime-name: restful-webservices-beginner.war) in 35ms
16:31:41,220 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment null (runtime-name: ejb-beginner-sessions-war.war) in 36ms
16:31:41,226 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015877: Stopped deployment ejb-beginner-sessions-ear.ear (runtime-name: ejb-beginner-sessions-ear.ear) in 42ms
16:31:41,237 INFO  [org.jboss.as.controller] (HttpManagementService-threads - 1) JBAS014774: Service status report
JBAS014775:    New missing/unsatisfied dependencies:
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-impl.jar".component.StudentServiceBean.CREATE (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-impl.jar".component.StudentServiceBean.START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-impl.jar".component.StudentServiceBean.START (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-impl.jar".deploymentCompleteService, service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-impl.jar".moduleDeploymentRuntimeInformationStart] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-impl.jar".component.StudentServiceBean.VIEW."com.ejb.beginner.sessions.api.StudentService".LOCAL (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-impl.jar".component.StudentServiceBean.START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-impl.jar".component.StudentServiceBean.WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-impl.jar".component.StudentServiceBean.START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-impl.jar".deploymentCompleteService (missing) dependents: [service jboss.deployment.unit."ejb-beginner-sessions-ear.ear".deploymentCompleteService] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-impl.jar".jndiDependencyService (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-impl.jar".component.StudentServiceBean.START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-impl.jar".moduleDeploymentRuntimeInformation (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-impl.jar".moduleDeploymentRuntimeInformationStart, service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-impl.jar".component.StudentServiceBean.START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."com.ejb.beginner.sessions.web.MyRestfulService".CREATE (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."com.ejb.beginner.sessions.web.MyRestfulService".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."com.ejb.beginner.sessions.web.MyRestfulService".START (missing) dependents: [service jboss.web.deployment.default-host./ejb-beginner-sessions-war, service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".deploymentCompleteService] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."com.ejb.beginner.sessions.web.MyRestfulService".WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."com.ejb.beginner.sessions.web.MyRestfulService".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."com.ejb.beginner.sessions.web.StudentController".CREATE (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."com.ejb.beginner.sessions.web.StudentController".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."com.ejb.beginner.sessions.web.StudentController".START (missing) dependents: [service jboss.web.deployment.default-host./ejb-beginner-sessions-war, service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".deploymentCompleteService] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."com.ejb.beginner.sessions.web.StudentController".WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."com.ejb.beginner.sessions.web.StudentController".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."com.sun.faces.config.ConfigureListener".CREATE (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."com.sun.faces.config.ConfigureListener".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."com.sun.faces.config.ConfigureListener".START (missing) dependents: [service jboss.web.deployment.default-host./ejb-beginner-sessions-war, service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".deploymentCompleteService] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."com.sun.faces.config.ConfigureListener".WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."com.sun.faces.config.ConfigureListener".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."javax.faces.webapp.FacetTag".CREATE (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."javax.faces.webapp.FacetTag".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."javax.faces.webapp.FacetTag".START (missing) dependents: [service jboss.web.deployment.default-host./ejb-beginner-sessions-war, service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".deploymentCompleteService] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."javax.faces.webapp.FacetTag".WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."javax.faces.webapp.FacetTag".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".CREATE (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START (missing) dependents: [service jboss.web.deployment.default-host./ejb-beginner-sessions-war, service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".deploymentCompleteService] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".CREATE (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".START (missing) dependents: [service jboss.web.deployment.default-host./ejb-beginner-sessions-war, service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".deploymentCompleteService] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."org.apache.catalina.servlets.DefaultServlet".START (missing) dependents: [service jboss.web.deployment.default-host./ejb-beginner-sessions-war, service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".deploymentCompleteService] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."org.apache.catalina.servlets.DefaultServlet".WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."org.apache.catalina.servlets.DefaultServlet".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."org.apache.jasper.servlet.JspServlet".CREATE (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."org.apache.jasper.servlet.JspServlet".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."org.apache.jasper.servlet.JspServlet".START (missing) dependents: [service jboss.web.deployment.default-host./ejb-beginner-sessions-war, service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".deploymentCompleteService] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."org.apache.jasper.servlet.JspServlet".WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."org.apache.jasper.servlet.JspServlet".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."org.jboss.as.weld.webtier.jsp.JspInitializationListener".CREATE (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."org.jboss.as.weld.webtier.jsp.JspInitializationListener".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."org.jboss.as.weld.webtier.jsp.JspInitializationListener".START (missing) dependents: [service jboss.web.deployment.default-host./ejb-beginner-sessions-war, service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".deploymentCompleteService] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."org.jboss.as.weld.webtier.jsp.JspInitializationListener".WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."org.jboss.as.weld.webtier.jsp.JspInitializationListener".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".deploymentCompleteService (missing) dependents: [service jboss.deployment.unit."ejb-beginner-sessions-ear.ear".deploymentCompleteService] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".jndiDependencyService (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."com.ejb.beginner.sessions.web.StudentController".START, service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."org.jboss.as.weld.webtier.jsp.JspInitializationListener".START, service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".component."javax.faces.webapp.FacetTag".START, service jboss.web.deployment.default-host./ejb-beginner-sessions-war, JBAS014799: ... and 4 more ] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."com.sun.faces.config.ConfigureListener".CREATE (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."com.sun.faces.config.ConfigureListener".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."com.sun.faces.config.ConfigureListener".START (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".deploymentCompleteService, service jboss.web.deployment.default-host./restful-webservices-beginner] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."com.sun.faces.config.ConfigureListener".WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."com.sun.faces.config.ConfigureListener".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.faces.webapp.FacetTag".CREATE (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.faces.webapp.FacetTag".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.faces.webapp.FacetTag".START (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".deploymentCompleteService, service jboss.web.deployment.default-host./restful-webservices-beginner] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.faces.webapp.FacetTag".WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.faces.webapp.FacetTag".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".CREATE (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".deploymentCompleteService, service jboss.web.deployment.default-host./restful-webservices-beginner] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".CREATE (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".START (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".deploymentCompleteService, service jboss.web.deployment.default-host./restful-webservices-beginner] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.ws.rs.core.Application".CREATE (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.ws.rs.core.Application".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.ws.rs.core.Application".START (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".deploymentCompleteService, service jboss.web.deployment.default-host./restful-webservices-beginner] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.ws.rs.core.Application".WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."javax.ws.rs.core.Application".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."org.apache.catalina.servlets.DefaultServlet".CREATE (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."org.apache.catalina.servlets.DefaultServlet".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."org.apache.catalina.servlets.DefaultServlet".START (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".deploymentCompleteService, service jboss.web.deployment.default-host./restful-webservices-beginner] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."org.apache.catalina.servlets.DefaultServlet".WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."org.apache.catalina.servlets.DefaultServlet".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."org.apache.jasper.servlet.JspServlet".CREATE (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."org.apache.jasper.servlet.JspServlet".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."org.apache.jasper.servlet.JspServlet".START (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".deploymentCompleteService, service jboss.web.deployment.default-host./restful-webservices-beginner] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."org.apache.jasper.servlet.JspServlet".WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."org.apache.jasper.servlet.JspServlet".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."org.jboss.as.weld.webtier.jsp.JspInitializationListener".CREATE (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."org.jboss.as.weld.webtier.jsp.JspInitializationListener".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."org.jboss.as.weld.webtier.jsp.JspInitializationListener".START (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".deploymentCompleteService, service jboss.web.deployment.default-host./restful-webservices-beginner] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."org.jboss.as.weld.webtier.jsp.JspInitializationListener".WeldInstantiator (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".component."org.jboss.as.weld.webtier.jsp.JspInitializationListener".START] 
      service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".deploymentCompleteService (missing) dependents: [service jboss.deployment.unit."ejb-beginner-sessions-ear.ear".deploymentCompleteService] 
      service jboss.naming.context.java.comp.ejb-beginner-sessions-ear.ejb-beginner-sessions-impl.StudentServiceBean (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-impl.jar".component.StudentServiceBean.START] 
      service jboss.web.deployment.default-host./ejb-beginner-sessions-war (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".deploymentCompleteService] 
      service jboss.web.deployment.default-host./ejb-beginner-sessions-war.realm (missing) dependents: [service jboss.web.deployment.default-host./ejb-beginner-sessions-war, service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."ejb-beginner-sessions-war.war".deploymentCompleteService] 
      service jboss.web.deployment.default-host./restful-webservices-beginner (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".deploymentCompleteService] 
      service jboss.web.deployment.default-host./restful-webservices-beginner.realm (missing) dependents: [service jboss.deployment.subunit."ejb-beginner-sessions-ear.ear"."restful-webservices-beginner.war".deploymentCompleteService, service jboss.web.deployment.default-host./restful-webservices-beginner] 
JBAS014777:   Services which failed to start:      service jboss.deployment.unit."ejb-beginner-sessions-ear.ear".WeldStartService

We have different implementations for an interface and at runtime we want to resolve which one to use. So we used javax.enterprise.inject.Instance. We pass a custom annotation to the select method of Instance and returns the appropriate implementation. The implementation are annotated with the custom annotation. This is how we are injecting all instances and using the appropriate instance. Below is a sample snippet

@Inject
@Any
private Instance<SoftwarePackageDescriptorProvider> descriptorProviders;
descriptorProviders.select(new PlatformQualifier(platformType)).get();
1

There are 1 answers

2
goblingift On

Not sure if there is a way to get a dynamic list of all implementation classes, but you could use a qualifier, to say which specific class you want:

@Inject 
@Named("ClassB")
private ClassB impl;