Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-4340

Managed converter can not be injected into other CDI bean

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.6
    • 2.3-next-M3
    • None
    • None

    Description

      If CDI bean injects a managed converter with @FacesConverter @Qualifier, AmbiguousResolutionException will be thrown

       

      org.apache.webbeans.exception.WebBeansDeploymentException: javax.enterprise.inject.AmbiguousResolutionException: There is more than one Bean with type cz.krpata.jsf23.UserConverter Qualifiers: [@javax.faces.convert.FacesConverter(value=, forClass=class cz.krpata.jsf23.User, managed=true)]
      for injection into Field Injection Point, field name :  userConverter, Bean Owner : [InjectConverterIntoBean, WebBeansType:MANAGED, Name:injectConverterIntoBean, API Types:[cz.krpata.jsf23.InjectConverterIntoBean,java.lang.Object], Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any,javax.inject.Named]]
      found beans: 
      UserConverter, WebBeansType:THIRDPARTY, Name:null, API Types:[cz.krpata.jsf23.UserConverter,java.lang.Object], Qualifiers:[javax.enterprise.inject.Any,javax.faces.convert.FacesConverter] from file:/C:/Users/krpata/eclipse-2020-03-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp4/wtpwebapps/PFCsvTest-myfaces/WEB-INF/classes/cz/krpata/jsf23/UserConverter.class
      UserConverter, WebBeansType:MANAGED, Name:null, API Types:[cz.krpata.jsf23.UserConverter,java.lang.Object,javax.faces.convert.Converter<cz.krpata.jsf23.User>], Qualifiers:[javax.enterprise.inject.Any,javax.faces.convert.FacesConverter] from file:/C:/Users/krpata/eclipse-2020-03-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp4/wtpwebapps/PFCsvTest-myfaces/WEB-INF/classes/cz/krpata/jsf23/UserConverter.class
      
      

       

      Dependencies:

      • MyFaces 2.3.6
      • CDI (OWB) 2.0.14

      Classes:

       

      @FacesConverter(forClass=User.class, managed = true)
      public class UserConverter implements Converter<User> {	@Inject
      	private UserDAO userDAO;
      	
      	@Override
      	public User getAsObject(final FacesContext facesContext, final UIComponent uiComponent, final String name) {
      		return userDAO.getUserByName(name);
      	}
      
      	@Override
      	public String getAsString(final FacesContext facesContext, final UIComponent uiComponent, final User user) {
      		return user.getFirstname() + " " + user.getSurname();
      	}
      }
      
      @RequestScoped
      @Named
      public class InjectConverterIntoBean {
      	
      	@Inject
      	@FacesConverter(forClass=User.class, managed = true)
      	private UserConverter userConverter;
      
              ...	
      }
      

       

       

      Attachments

        Activity

          People

            tandraschko Thomas Andraschko
            krpata Jan Krpata
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: