title: How to use qualifier on non default class with java cdi
body: <p>I am trying to use @Qualifier to create an annotation on an Alternative class that will be used instead of the default class marked with @Default. However , when I do this weld reports the error. I am trying to inject demo.cdi.ProductB (the default is demo.cdi.ProductA)</p>
  
  <p>This is the error I get:</p>
  
  <pre><code>Exception in thread "main" org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Product with qualifiers @Video
    at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedMethod] @Inject public demo.cdi.OrderManagementImpl2.OrderManagementImpl2(@Video Product)
    at demo.cdi.OrderManagementImpl2.OrderManagementImpl2(OrderManagementImpl2.java:0)
  WELD-001475: The following beans match by type, but none have matching qualifiers:
    - Managed Bean [class demo.cdi.productA] with qualifiers [@Default @Any]
  </code></pre>
  
  <p>if I modify beans.xml by adding other alternatives I get the error below:</p>
  
  <pre><code>&lt;beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"&gt;
      &lt;alternatives&gt;
          &lt;!-- &lt;class&gt;demo.cdi.ProductA&lt;/class&gt; --&gt;
          &lt;class&gt;demo.cdi.ProductB&lt;/class&gt;
          &lt;class&gt;demo.cdi.ProductC&lt;/class&gt;
          &lt;class&gt;demo.cdi.productD&lt;/class&gt;
      &lt;/alternatives&gt;
  &lt;/beans&gt;      
  </code></pre>
  
  <p>(the error):</p>
  
  <pre><code>org.jboss.weld.exceptions.DeploymentException: WELD-001409:
      Ambiguous dependencies for type Product with qualifiers @Default
  </code></pre>
  
  <p>How do I create Qualifier notations for the non-default class?</p>
  
  <p>the rest of the code is below for reference:</p>
  
  <p>(ProductA):</p>
  
  <pre><code>package demo.cdi;
  import java.util.LinkedList;
  import javax.enterprise.inject.Default;
  
  @Default
  public class ProductA implements Product
  {
      @Override
      public LinkedList&lt;Feature&gt; getFeatures()
      {
          LinkedList&lt;Feature&gt; rtn = new LinkedList&lt;Feature&gt;();
          rtn.add(new Feature("FKA", "FVA"));
          return rtn;
      }
  
  }
  </code></pre>
  
  <p>(VideoProduct):</p>
  
  <pre><code>package demo.cdi;
  import java.util.LinkedList;
  import javax.enterprise.inject.Alternative;
  import javax.enterprise.inject.Produces;
  
  @Alternative
  @Video
  public class VideoProduct implements Product
  {
      private VideoProduct() {}
  
      @Produces
      public Product factoryCreate()
      {
          return new VideoProduct();
      }
  
      @Override
      public LinkedList&lt;Feature&gt; getFeatures()
      {
          LinkedList&lt;Feature&gt; rtn = new LinkedList&lt;Feature&gt;();
          rtn.add( new Feature("FKB","FVB") );
          return rtn;
      }
  
  }
  </code></pre>
  
  <p>(Video):</p>
  
  <pre><code>package demo.cdi;    
  import java.lang.annotation.Retention;
  import java.lang.annotation.Target;
  import static java.lang.annotation.ElementType.*;
  import static java.lang.annotation.RetentionPolicy.*;    
  import javax.inject.Qualifier;    
  
  @Qualifier
  @Retention(RUNTIME)
  @Target({TYPE, METHOD, FIELD, PARAMETER})
  public @interface Video
  {
  
  } 
  </code></pre>
  
  <p>(OrderManagementImpl2):</p>
  
  <pre><code>package demo.cdi;
  import javax.inject.Inject;
  import javax.inject.Named;
  
  public class OrderManagementImpl2 implements OrderManagement
  {
      private Product product = null;
  
      @Inject
      public void OrderManagementImpl2(@Video Product _product)
      {
          System.out.println(" [ setProduct ] [ _product = "+_product+"]");
          this.product=_product;
      }
  
      @Override
      public void createProduct()
      {
          System.out.println(" [ createProduct ] [ product = "+product+"]");
      }
  }
  </code></pre>
  
  <p>(MainApp2):</p>
  
  <pre><code>package demo.cdi;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import org.jboss.weld.Container;
  import org.jboss.weld.environment.se.Weld;
  import org.jboss.weld.environment.se.WeldContainer;
  
  public class MainApp2
  {
      public static void main(String[] args)
      {
          Weld weld = new Weld();
          WeldContainer weldContainer = weld.initialize();
          OrderManagementImpl2 impl = weldContainer.instance().select(OrderManagementImpl2.class).get();
          impl.createProduct();
          weld.shutdown();
      }
  } 
  </code></pre>