Uploaded image for project: 'Seam Faces'
  1. Seam Faces
  2. SEAMFACES-242

WELD-001318 AmbiguousResolutionException with Converter having subclass

    Details

    • Type: Bug
    • Status: Pull Request Sent (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.1.0.Final
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      GF 3.1.2 with JDK 1.6.0b29 + SeamFaces 3.1.0 + RichFaces 4.2.0

    • Steps to Reproduce:
      Hide

      Create a jsf converter. Use it in a jsf page. Subclass the converter.

      Show
      Create a jsf converter. Use it in a jsf page. Subclass the converter.
    • Workaround Description:
      Hide

      The 3 converters in the example can derive from one abstract class. Then the resolution is unambiguous.

      Show
      The 3 converters in the example can derive from one abstract class. Then the resolution is unambiguous.
    • Estimated Difficulty:
      Low

      Description

      On some page I have <rich:inputNumberSpinner label="Count" value="#

      {orderLine.quantity}

      " converter="IntegerOrNullConverter".../>

      The converter to use is explicit. But I also extended that converter class twice for other purposes.
      When accessing the page I get a WELD-001318 ambiguous dependency. Stacktrace below.

      SeamApplicationWrapper#createConverter ends up calling BeanManagerUtils#isDependentScoped which tries to CDI-resolve the the converter type. Naturally weld finds the 3 converters (the one I asked for and the 2 subclasses) and it complains as it should. I strongly believe calling BM#resolve here is wrong.
      The same will happen with SeamApplicationWrapper#createValidator.

      1) These methods should deal with only the actual requested type
      2) The use of BeanManagerUtils.getContextualInstance in SeamApplicationWrapper.attemptExtension will also lead to problems.
      3) More generally, I BeanManagerUtils.isDependentScoped isn't selective enough either

      Instead of #resolve, another utility method like this may be called:

          public <T> Set<Bean<?>> getExactBeanForType(final Class<T> type) {
            Set<Bean<?>> beans = manager.getBeans(type);
      
            for(Bean<?> bean : beans) {
              if(type.equals(bean.getBeanClass())) {
                return Collections.<Bean<?>>singleton(bean);
              }
            }
            
            return Collections.<Bean<?>>emptySet();
          }
      

      Stacktrace of the issue:

      GRAVE: org.jboss.weld.exceptions.AmbiguousResolutionException: WELD-001318 Cannot resolve an ambiguous dependency between [Managed Bean [class org.mars.toolkit.jsf.converter.MonthConverter] with qualifiers [@Any @Default], Managed Bean [class org.mars.toolkit.jsf.converter.IntegerOrNullConverter] with qualifiers [@Any @Default], Managed Bean [class org.mars.toolkit.jsf.converter.YearConverter] with qualifiers [@Any @Default]]
          at org.jboss.weld.manager.BeanManagerImpl.resolve(BeanManagerImpl.java:1013)
          at org.jboss.seam.faces.util.BeanManagerUtils.isDependentScoped(BeanManagerUtils.java:74)
          at org.jboss.seam.faces.environment.SeamApplicationWrapper.attemptExtension(SeamApplicationWrapper.java:81)
          at org.jboss.seam.faces.environment.SeamApplicationWrapper.createConverter(SeamApplicationWrapper.java:60)
          at org.jboss.seam.faces.environment.SeamApplicationWrapper$Proxy$_$$_WeldClientProxy.createConverter(SeamApplicationWrapper$Proxy$_$$_WeldClientProxy.java)
          at com.sun.faces.facelets.tag.jsf.ValueHolderRule$LiteralConverterMetadata.applyMetadata(ValueHolderRule.java:85)
          at com.sun.faces.facelets.tag.MetadataImpl.applyMetadata(MetadataImpl.java:81)
          at javax.faces.view.facelets.MetaTagHandler.setAttributes(MetaTagHandler.java:129)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.setAttributes(DelegatingMetaTagHandler.java:102)
          at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.setAttributes(BehaviorsAddingComponentHandlerWrapper.java:113)
          at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.doNewComponentActions(ComponentTagHandlerDelegateImpl.java:409)
          at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:159)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
          at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
          at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
          at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
          at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
          at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
          at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
          at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
          at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
          at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
          at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
          at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
          at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
          at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
          at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
          at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
          at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
          at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
          at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
          at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandle.java:137)
          at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BeaviorsAddingComponentHandlerWrapper.java:53)
          at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelgateImpl.java:184)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
          at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
          at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
          at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)
          at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:308)
          at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:367)
          at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:346)
          at com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:199)
          at com.sun.faces.facelets.tag.ui.IncludeHandler.apply(IncludeHandler.java:120)
          at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
          at com.sun.faces.facelets.tag.ui.DefineHandler.applyDefinition(DefineHandler.java:107)
          at com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:178)
          at com.sun.faces.facelets.impl.DefaultFaceletContext$TemplateManager.apply(DefaultFaceletContext.java:395)
          at com.sun.faces.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:366)
          at com.sun.faces.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:112)
          at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
          at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
          at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
          at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
          at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
          at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:53)
          at com.sun.faces.
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                fabmars Fab Mars
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: