2 Replies Latest reply on Jan 31, 2011 1:55 AM by infinity2heaven

    WELD-001414 Bean name is ambiguous - Understanding @Any @Default

    infinity2heaven Novice

      I have a sample project extending weld-login example that comes with weld-1.1 dist.


      public class Credentials {
          private String username;
          private String password;


      public class Authenticator
           implements Serializable {
           private static final long serialVersionUID = 1L;
           private Credentials credentials;
           private User currentUser;
           private EntityManager em;
           @SuppressWarnings( "unchecked" )
           public void login() {
                List< User > results =
                          "select u from User u where u.credential.username=:username and u.credential.password=:password" ).setParameter(
                          credentials.getUsername() ).setParameter( "password", credentials.getPassword() ).getResultList();
                if ( !results.isEmpty() ) {
                     currentUser = results.get( 0 );
                          new FacesMessage( "Welcome, " + currentUser.getName() ) );
           public void logout() {
                     new FacesMessage( "Goodbye, " + currentUser.getName() ) );
                currentUser = null;
           public boolean isLoggedIn() {
                return currentUser != null;
           public User getCurrentUser() {
                return currentUser;
           @SuppressWarnings( "unchecked" )
           public List< User > getUsers() {
                return em.createQuery( "select u from User u" ).getResultList();

      I get the following on deploying to JBoss 6.0. I'm using Sea, 3.0 beta, Seam-solder jars in my war file. And that's the only difference from the weld-login project (which I'm abel to run and deploy).

      WELD-001414 Bean name is ambiguous. Name credentials resolves to beans [Managed Bean [class xxx.security.Credentials] with qualifiers [@Any @Default], Managed Bean [class org.jboss.seam.security.CredentialsImpl] with qualifiers [@Any @Default @Named]]
           at org.jboss.weld.bootstrap.Validator.validateBeanNames(Validator.java:472) [:6.0.0.Final]

      I don't think I understand the concepts of @Any, @Default at all. What is the wrong with the above code (since it works in the example project)