title: CDI producer not recognized with qualifiers
body: <p>I have an EAR application with 2 modules. A WEB and an EJB module.</p>
  
  <p>There are several services in the EJB module which are injected into classes of the WEB module, which works fine. But some services need configurations based on the user context which is only available in the WEB module. So I tried to add a producer to the WEB module.<br>
  The structure looks like this:</p>
  
  <pre><code>app-ear
  |
  +- app-ejb
  |   |
  |   +- Service
  |   +- ServiceConnector
  |
  +- app-web
      |
      +- ServiceConnectorProducer
  </code></pre>
  
  <p>Here is a simplified version of that code:</p>
  
  <p>Service class which gets a connector injected into: (EJB)</p>
  
  <pre><code>public class Service {
      @Inject
      private ServiceConnector connector;
  }
  </code></pre>
  
  <p>Connector class which will handle the connection for a service: (EJB)</p>
  
  <pre><code>public class ServiceConnector {
      private final Config config;
  
      public ServiceConnector(final Config config) {
          this.config = config;
      }
  }
  </code></pre>
  
  <p>Producer for <code>ServiceConnector</code>: (WEB)</p>
  
  <pre><code>public class ServiceConnectorProducer {
      @Produces
      public ServiceConnector produce(UserContext userCtx) {
          // ... create config and set data from user context
          return new ServiceConnector(config);
      }
  }
  </code></pre>
  
  <p>At this point the producer is not recognized at the injection point and I get an unsatisfied dependency error:</p>
  
  <pre><code>org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type ServiceConnector with qualifiers @Default
    at injection point [BackedAnnotatedField] @Inject private Service.connector
    at Service.connector(Service.java:0)
  </code></pre>
  
  <p>This happen even though the producer was loaded by the container:</p>
  
  <pre><code>WELD-000106: Bean: Producer Method [ServiceConenctor] with qualifiers [@Any @Default] declared as [[BackedAnnotatedMethod] @Produces public ServiceConenctorProducer.produce(UserContext)]
  </code></pre>
  
  <p>When I make the <code>ServiceConnector</code> discoverable by the container by adding a default constructor I however get an ambiguous dependencies error:</p>
  
  <pre><code>Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001409: Ambiguous dependencies for type ServiceConnector with qualifiers @Default
  at injection point [BackedAnnotatedField] @Inject private Service.connector
  at Service.connector(Service.java:0)
  Possible dependencies: 
  - Producer Method [ServiceConnector] with qualifiers [@Any @Default] declared as [[BackedAnnotatedMethod] @Produces public ServiceConnector.produce(UserContext)],
  - Managed Bean [class ServiceConnector] with qualifiers [@Any @Default]
  </code></pre>
  
  <p>After that I tried the following things to resolve the ambiguous dependencies.<br>
  - <a href="https://stackoverflow.com/a/22985035">https://stackoverflow.com/a/22985035</a> (Add qualifier)<br>
  - <a href="https://stackoverflow.com/a/36056972">https://stackoverflow.com/a/36056972</a> (Use <code>@Any</code>)<br>
  - <a href="https://stackoverflow.com/a/29449040/11117616">https://stackoverflow.com/a/29449040/11117616</a> (Use <code>@Vetoed</code>)</p>
  
  <p>But all these solutions lead back to the unsatisfied dependency error.</p>
  
  <pre><code>WELD-001408: Unsatisfied dependencies for type ServiceConnector with qualifiers @SessionService
    at injection point [BackedAnnotatedField] @Inject @SessionService private Service.connector
    at Service.connector(Service.java:0)
  WELD-001475: The following beans match by type, but none have matching qualifiers:
    - Managed Bean [class ServiceConnector] with qualifiers [@Any @Default]
  </code></pre>
  
  <p>So now I am out of ideas how to resolve the situation. How can I get the <code>ServiceConnector</code> to be produced in the WEB module?</p>