title: Unsatisfied dependencies for type [...] with qualifiers [@Default] at injection point (using @Stateful EJB with CDI)
body: <p>I have the following code to manage two kinds of repositories. Both repository classes inherit an interface to allow reinitialization of their resources.</p>
  
  <pre><code>public interface CachingRepository
  {
      public void invalidateCache();
  }
  </code></pre>
  
  <p>Global, application-scoped repo:</p>
  
  <pre><code>@Named("globalRepo")
  @ApplicationScoped
  public class GlobalRepository implements CachingRepository
  {
      private List&lt;Category&gt; categories;
  
      ...
  
      @Override
      public void invalidateCache()
      {
          categories = null;
      }
  
      ...
  }
  </code></pre>
  
  <p>Per user, session-scoped repo:</p>
  
  <pre><code>@Named("userRepo")
  @SessionScoped
  //@Stateful         // &lt;- NOTE HERE
  public class UserRepository implements CachingRepository, Serializable
  {
      private List&lt;MyFile&gt; files;
  
      @Override
      public void invalidateCache()
      {
          files = null;
      }
  
      ...
  }
  </code></pre>
  
  <p>When injecting this (without <code>@Stateful</code>) into the context</p>
  
  <pre><code>@Named
  @ViewScoped
  public class MyHandler implements Serializable
  {
      @Inject
      private UserRepository userRepo;
  
      ...
  }
  </code></pre>
  
  <p>it works. However, when adding <code>@Stateful</code> to the <code>UserRepository</code> class, deployment fails with an exception saying:</p>
  
  <pre><code>Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [UserRepository] with qualifiers [@Default] at injection point [[field] @Inject private de.company.project.pack.MyHandler.userRepo]
      at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:275)
      at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:244)
      at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:107)
      at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:127)
      at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:346)
      at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:331)
      at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:366)
      at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:83)
      at org.jboss.as.weld.services.WeldService.start(WeldService.java:76)
      ... 5 more
  </code></pre>
  
  <p>Adding the name of the CDI bean like</p>
  
  <pre><code>@Inject @Named("userRepo")
  private UserRepository userRepo;
  </code></pre>
  
  <p>results in the same exception. The only thing that works in conjunction with <code>@Stateful</code> is to use the interface in the var declaration:</p>
  
  <pre><code>@Inject @Named("userRepo")
  private CachingRepository userRepo;
  </code></pre>
  
  <p>I might need sub class functionality here however, so using <code>CachingRepository</code> isn't really desired (at the moment).</p>
  
  <p><strong>Q's</strong>:</p>
  
  <ol>
  <li>Why isn't this working as expected? The <code>UserRepository</code> var should already identify which class to instantiate, shouldn't it? What's the logic to this?</li>
  <li>Why does the <code>@Stateful</code> EJB annotation have such severe effects here? Why does it essentially force me into using the <code>CachingRepository</code> interface in the var declaration?</li>
  </ol>
  
  <hr>
  
  <p><strong>Note</strong>, I' using Seam 3 Faces making the <code>@ViewScoped</code> become a CDI view-scoped bean, so the problem at hand is likely still <strong>CDI-only</strong>.</p>