title: Weld cannot find CDI producer
body: <p>WildFly 10.1 used. In modules added single module that contains jar file with interface EzRegistryService.</p>
  
  <p>Producer code:</p>
  
  <pre><code>package com.ejbtest;
  
  import org.apache.log4j.Logger;
  
  import javax.ejb.EJB;
  import javax.enterprise.context.ApplicationScoped;
  import javax.enterprise.inject.Default;
  import javax.enterprise.inject.Produces;
  import javax.naming.InitialContext;
  import javax.naming.NamingException;
  
  public class Resources {
      private static final Logger log = Logger.getLogger(Resources.class);
      public static final String jndiName = "java:global/ejbtest.main/EzRegistryServiceBean!com.ejbtest.EzRegistryService";
  
      //also didn't work
      //@Produces
      //@EJB(lookup = jndiName)
      //private EzRegistryService ezRegistryService;
  
      // didn't work
      @Produces
      public EzRegistryService getEzRegistryService() {
          log.info("getEzRegistryService called");
          try {
              InitialContext ctx = new InitialContext();
              Object service = ctx.lookup(jndiName);
              log.info("Found: " + service);
              return (EzRegistryService) service;
          } catch (NamingException e) {
              log.error("Exception while getting EzRegistryService", e);
              return null;
          }
      }
  }
  </code></pre>
  
  <p>Singleton bean:</p>
  
  <pre><code>package com.ejbtest;
  
  import org.apache.log4j.Logger;
  
  import javax.annotation.PostConstruct;
  import javax.annotation.PreDestroy;
  import javax.ejb.EJB;
  import javax.ejb.Singleton;
  import javax.ejb.Startup;
  import javax.inject.Inject;
  
  @Singleton
  @Startup
  public class MyGateStartup {
      private static final Logger log = Logger.getLogger(MyGateStartup.class);
  
      //@EJB(mappedName = Resources.jndiName) //works fine
      @Inject
      private EzRegistryService service;
  
      @PostConstruct
      public void start() {
          log.info("MyGateStartup started");
          //...
      }
  
      @PreDestroy
      public void end() {
          //...
          log.info("MyGateStartup stopped");
      }
  
  }
  </code></pre>
  
  <p>beans.xml in WEB-INF folder:</p>
  
  <pre><code>&lt;beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
         version="1.1"
         bean-discovery-mode="all"&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>WildFly can't deploy resulting war-file:</p>
  
  <pre><code>2017-03-14 13:15:05,237 MSC service thread 1-8 INFO  [org.jboss.weld.deployer] WFLYWELD0006: Starting Services for CDI deployment: ejbtest.gate-1.0-SNAPSHOT.war
  2017-03-14 13:15:05,241 MSC service thread 1-8 INFO  [org.jboss.weld.deployer] WFLYWELD0009: Starting weld service for deployment ejbtest.gate-1.0-SNAPSHOT.war
  2017-03-14 13:15:05,299 MSC service thread 1-6 ERROR [org.jboss.msc.service.fail] MSC000001: Failed to start service jboss.deployment.unit."ejbtest.gate-1.0-SNAPSHOT.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."ejbtest.gate-1.0-SNAPSHOT.war".WeldStartService: Failed to start service
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.6.Final.jar:1.2.6.Final]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_121]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_121]
      at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_121]
  Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type EzRegistryService with qualifiers @Default
    at injection point [BackedAnnotatedField] @Inject private com.ejbtest.MyGateStartup.service
    at com.ejbtest.MyGateStartup.service(MyGateStartup.java:0)
  </code></pre>
  
  <p>Why CDI can't find producer in Resources class?</p>