title: Why Wildfly says that at deploy my REST resource file is annotated with @RequestScoped, however it is not?
body: <p>I have a REST service implemented by Resteasy. In the service I inject (by Guice) an application (implements business logic and has injected EJB too) which has @EJB injected. When I deploy it Wildfly 10 gives me the exception at the bottom.</p>
  
  <p>Just searching for the error message I have found that I might have CDI (Weld?) misconfigurated.</p>
  
  <pre><code> [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 9) WELD-000167: Class digitallibrary.masterdata.dataservice.rest.api.resources.CurrencyResource is annotated with @RequestScoped but it does not declare an appropriate constructor therefore is not registered as a bean!
  </code></pre>
  
  <p>I have a few questions because I'm new at this area, and I need some direction to move forward because I don't know whether I haven't read something to have this app up and running and I met a strange case.</p>
  
  <ul>
  <li>How Weld comes into picture around @EJB? I know somehow my session bean is injected, but I had the feeling it happens without any configuration needs.</li>
  <li>Why Weld thinks that my CurrencyResource class is annotated? It is not.</li>
  <li>Does it always need configuration? I have checked Wildfly examples project on Github and I haven't seen configuration.</li>
  <li>Do I have to use beans.xml?</li>
  <li>It is possible that nested injection causes this problem?</li>
  <li>do you need any other code sample from my project?</li>
  </ul>
  
  <p>Please find my application code below:</p>
  
  <p>Resteasy resource class:</p>
  
  <pre><code>@Path("/currency")
  public class CurrencyResource {
  
      private final CurrencyAppInterface currencyApp;
  
      @com.google.inject.Inject
      public CurrencyResource(final CurrencyAppInterface currencyApp) {
          this.currencyApp = currencyApp;
      }
  
      @GET
      @Path("/currencies")
      @Produces(MediaType.APPLICATION_JSON)
      public Response getCurrencies() {
          System.out.println("stuff");
          Collection&lt;String&gt; currencies = new ArrayList&lt;String&gt;();
          currencies.add("curr1");
          currencies.add("curr2");
  
          return Response
                  .status(Response.Status.OK)
                  .entity(currencies)
                  .build();
      }
  }
  </code></pre>
  
  <p>Resteasy application file:</p>
  
  <pre><code>@ApplicationPath("/api")
  public class DigitalLibraryMasterDataDataservice extends Application {
  
      private Set&lt;Object&gt; singletons = new HashSet&lt;Object&gt;();
  
      public DigitalLibraryMasterDataDataservice(@Context ServletContext servletContext) {
      }
  
      @Override
      public Set&lt;Object&gt; getSingletons(){
          Injector injector = Guice.createInjector(new CurrencyModule());
  
          CurrencyModule currencyModule = injector.getInstance(CurrencyModule.class);
  
          singletons.add(currencyModule);
  
          return singletons;
      }
  }
  </code></pre>
  
  <p>Application file, implementing business logic and using the session bean.</p>
  
  <pre><code>public class CurrencyApplication implements CurrencyAppInterface {
  
      @EJB(name = "CurrencySessionBean")
      private CurrencySessionBean currencySessionBean;
  
      private CurrencyMapperInterface currencyMapper;
  
      @com.google.inject.Inject
      public CurrencyApplication(CurrencyMapper currencyMapper) {
          this.currencyMapper = currencyMapper;
      }
  
      @Override
      public Collection&lt;CurrencyDto&gt; getAllCurrencies() throws DigitalLibraryMasterDataDataserviceApplicationException {
  
          try {
  
              Collection&lt;Currency&gt; currencies = this.currencySessionBean.getAllCurrencies();
              Collection&lt;CurrencyDto&gt; mappedCurrencies = this.currencyMapper.MapCurrenciesToCurrencyDtos(currencies);
              return mappedCurrencies;
  
          } catch (Exception e) {
  
              throw new DigitalLibraryMasterDataDataserviceApplicationException("Error in application", e);
  
          }
      }
  }
  </code></pre>
  
  <p>The Session Bean:</p>
  
  <pre><code>@Stateless
  public class CurrencySessionBean implements CurrencySessionBeanLocalInterface {
  
      @PersistenceContext(name = "DigitalLibrary.MasterData.Dataservice.PU")
      private EntityManager em;
  
      @Override
      public Collection&lt;Currency&gt; getAllCurrencies() throws DigitalLibraryMasterDataDataserviceEjbSessionBeanException {
  
          try {
  
              List&lt;Currency&gt; currencies = this.em.createQuery("from Currency", Currency.class).getResultList();
              return currencies;
          } catch (Exception e) {
  
              throw new DigitalLibraryMasterDataDataserviceEjbSessionBeanException("Error querying currencies", e);
          }
      }
  }
  </code></pre>
  
  <p>Full error message from Wildfly:</p>
  
  <pre><code>22:56:25,818 INFO  [org.hibernate.envers.boot.internal.EnversServiceImpl] (ServerService Thread Pool -- 69) Envers integration enabled? : true
  22:56:26,117 WARN  [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 9) WELD-000167: Class digitallibrary.masterdata.dataservice.rest.api.resources.CurrencyResource is annotated with @RequestScoped but it does not declare an appropriate constructor therefore is not registered as a bean!
  22:56:26,275 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC000001: Failed to start service jboss.deployment.unit."DigitalLibrary.MasterData.Dataservice.ear".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."DigitalLibrary.MasterData.Dataservice.ear".WeldStartService: Failed to start service
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          at java.lang.Thread.run(Thread.java:748)
  Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Injector with qualifiers @Default
    at injection point [BackedAnnotatedField] @Inject private org.jboss.resteasy.plugins.guice.GuiceResteasyBootstrapServletContextListener.parentInjector
    at org.jboss.resteasy.plugins.guice.GuiceResteasyBootstrapServletContextListener.parentInjector(GuiceResteasyBootstrapServletContextListener.java:0)
  
          at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:359)
          at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:281)
          at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
          at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:155)
          at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:518)
          at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
          at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
          at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
          at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
          at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          at java.lang.Thread.run(Thread.java:748)
          at org.jboss.threads.JBossThread.run(JBossThread.java:320)
  
  22:56:26,279 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" =&gt; "DigitalLibrary.MasterData.Dataservice.ear")]) - failure description: {
      "WFLYCTL0080: Failed services" =&gt; {"jboss.deployment.unit.\"DigitalLibrary.MasterData.Dataservice.ear\".WeldStartService" =&gt; "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"DigitalLibrary.MasterData.Dataservice.ear\".WeldStartService: Failed to start service
      Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Injector with qualifiers @Default
    at injection point [BackedAnnotatedField] @Inject private org.jboss.resteasy.plugins.guice.GuiceResteasyBootstrapServletContextListener.parentInjector
    at org.jboss.resteasy.plugins.guice.GuiceResteasyBootstrapServletContextListener.parentInjector(GuiceResteasyBootstrapServletContextListener.java:0) "}, "WFLYCTL0412: Required services that are not installed:" =&gt;["jboss.deployment.unit.\"DigitalLibrary.MasterData.Dataservice.ear\".WeldStartService"], "WFLYCTL0180: Services with missing/unavailable dependencies" =&gt; undefined }
  </code></pre>