2 Replies Latest reply on May 26, 2014 8:24 AM by Andrey Karandey

    Using qualifier has no effect (WELD-001475)

    Andrey Karandey Newbie

      Hi all! I am trying to emulate file resource injection (like Spring @Value) in CDI 1.1 using custom qualifier annotation @FileResource. So i have the following code:

       

      @MessageDriven(activationConfig = {@ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "jms/queue/RegistrationQueue")})

      public class RegistrationQueueProcessor implements MessageListener {

          @Inject

          @FileResource("/mail-templates/registration-mail.tpl")

          File mailTemplateFile;

       

          @Override

          public void onMessage(Message message) {

             //send mail

            }

      }

       

      @Singleton(name = "resourceManager")

      public class ResourceManager {

          @Produces

          @FileResource

          public File fileResourceInjector(InjectionPoint p) {

              String resourcePath = p.getAnnotated().getAnnotation(FileResource.class).value();

              return loadFileResource(resourcePath);

          }

      }

       

      On server startup i am getting an exception

       

      WELD-001408: Unsatisfied dependencies for type File with qualifiers @FileResource

        at injection point [BackedAnnotatedField] @Inject @FileResource com.teamba.security.registration.RegistrationQueueProcessor.mailTemplateFile

        at com.teamba.security.registration.RegistrationQueueProcessor.mailTemplateFile(RegistrationQueueProcessor.java:0)

      WELD-001475: The following beans match by type, but none have matching qualifiers:

        - Producer Method [File] with qualifiers [@FileResource @Any] declared as [[BackedAnnotatedMethod] @Produces @FileResource public com.mysite.cdi.ResourceManager.fileResourceInjector(InjectionPoint)],

        - Producer Method [File] with qualifiers [@BatchProperty @Any] declared as [[UnbackedAnnotatedMethod] @Produces @BatchProperty public org.jberet.creation.BatchBeanProducer.getFile(InjectionPoint)]

       

      I dont understand why it is happening. If there something wrong with EJB/CDI context intersection?

       

      WildFly 8.1.0.CR1 (Weld 2.1.2)

       

      Thanx in advance. I would appreciate any help..