11 Replies Latest reply on Mar 16, 2015 4:48 AM by Martin Kouba

    WELD-001408: Unsatisfied dependencies for type List with qualifiers

    abhi0123 Newbie

      I'm stuck with the infamous WELD-001408 that everyone programming with CDI has come across in one way or other. Using Oracle JDK 1.8.0_25, Wildfly 8.2.0.Final. My code is as follows:

      module availability-service (war) depends on module hospital-user (jar). Former has a beans.xml in WEB-INF and later in META-INF, even though CDI 1.1 doesn't require a beans.xml.

       

      In hospital-user (producer):

       

      @ApplicationScoped

      public class Users {

          @Produces

          @Doctors

          public List<Doctor> getDoctors() {

              return getUsers("/doctors.json", Doctor.class);

          }

       

          @Produces

          @Patients

          public List<Patient> getPatients() {

              return getUsers("/patients.json", Patient.class);

          }

      }

       

      Doctors annotation (Patients is similar except for the name):

       

      @Qualifier

      @Retention(RUNTIME)

      @Target({ FIELD, METHOD })

      public @interface Doctors {

      }

       

      In availability-service (injection target):

       

      @ApplicationScoped

      public class AvailabilityService {

          @Inject

          @Doctors

          private List<Doctor> doctors;

      }

       

      Error:

       

      Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type List<Doctor> with qualifiers @Doctors

        at injection point [BackedAnnotatedField] @Inject @Doctors private name.abhijitsarkar.microservices.availability.AvailabilityService.doctors

        at name.abhijitsarkar.microservices.availability.AvailabilityService.doctors(AvailabilityService.java:0)

       

       

          at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:372)

       

      If I inject the Users instead of the List, it works. What is going on here?

       

      For full disclosure, I've also asked this question on SO but didn't get a response.