title: CDI Ambiguous dependencies
body: <p>I have a <code>@SessionScoped @Named</code> bean with a <code>@Producer</code> method for a user object:</p>
  
  <pre><code>@Named @SessionScoped
  public class UserBean implements Serializable
  {
    //...
    @Named @Produces @LoggedIn @SessionScoped
    public MyUser getCurrentUser() {return user;}
  }
  </code></pre>
  
  <p>This works fine in my setup (JBoss-7.1.1-Final) and it's no problem to access the user fields from JSF pages with <code>#{currentUser.name}</code>. The qualifier is <code>org.jboss.seam.security.annotations.LoggedIn</code>. Now I want to <code>@Inject</code> this user in a field in another <code>@Named</code> Bean:</p>
  
  <pre><code>@Named
  public class FavBean implements Serializable
  {   
    private @Inject @LoggedIn MyUser currentUser;
  }
  </code></pre>
  
  <p>This gives me the error:</p>
  
  <pre><code>org.jboss.weld.exceptions.DeploymentException:
  WELD-001409 Ambiguous dependencies for type [MyUser] with qualifiers [@Default] at
    injection point [[field] @Inject @LoggedIn test.FavBean.currentUser].
  Possible dependencies [[Managed Bean [class test.ejb.MyUser] with qualifiers
    [@Any @Default],
  Producer Method [MyUser] with qualifiers [@Any @Default] declared as [[method]
    @Named @Produces @LoggedIn @SessionScoped public test.UserBean.getCurrentUser()]]]
  </code></pre>
  
  <p>I don't understand the first dependency <code>Managed Bean [class test.ejb.MyUser]</code> This class is a simple <code>@Entity</code> and deployed in an ebb.jar in a EAR. As a workaround I'm currently injecting the <code>UserBean</code> get the user from there.</p>