{"record":{"id":"a2bdb3a3b32203d1","repo":"quarkusio/quarkus","slug":"beans-resolvedbeans","errorCode":null,"errorMessage":"Beans: \" + resolvedBeans","messagePattern":"Beans: \" \\+ resolvedBeans","errorType":"exception","errorClass":"AmbiguousResolutionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ArcContainerImpl.java","lineNumber":328,"sourceCode":"\n    @Override\n    public <X> InstanceHandle<X> instance(Type type, Annotation... qualifiers) {\n        return instanceHandle(type, qualifiers);\n    }\n\n    @Override\n    public <T> Supplier<InstanceHandle<T>> beanInstanceSupplier(Class<T> type, Annotation... qualifiers) {\n        if (qualifiers == null || qualifiers.length == 0) {\n            qualifiers = new Annotation[] { Default.Literal.INSTANCE };\n        }\n        Resolvable resolvable = new Resolvable(type, qualifiers);\n        Set<InjectableBean<?>> resolvedBeans = resolved.getValue(resolvable);\n        if (resolvedBeans.isEmpty()) {\n            scanRemovedBeans(resolvable);\n        }\n        Set<InjectableBean<?>> filteredBean = resolvedBeans;\n        if (resolvedBeans.size() > 1) {\n            throw new AmbiguousResolutionException(\"Beans: \" + resolvedBeans);\n\n        }\n        @SuppressWarnings(\"unchecked\")\n        InjectableBean<T> bean = filteredBean.size() != 1 ? null\n                : (InjectableBean<T>) filteredBean.iterator().next();\n        if (bean == null) {\n            return null;\n        }\n        InjectionPoint injectionPoint = InjectionPointImpl.of(type, qualifiers);\n        return new Supplier<InstanceHandle<T>>() {\n            @Override\n            public InstanceHandle<T> get() {\n                return beanInstanceHandle(bean, null, injectionPoint, null);\n            }\n        };\n    }\n\n    @Override","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ArcContainerImpl.java#L310-L346","documentation":"Arc throws AmbiguousResolutionException when bean resolution for a required type/qualifier set matches more than one bean. CDI requires exactly one bean to resolve an injection point; the message lists all resolved beans so you can see the conflict. This enforces the CDI 'unresolvable ambiguous dependency' rule at injection time.","triggerScenarios":"Calling Instance.get()/beanInstanceSupplier resolution where two or more beans (e.g. two @Alternative-less implementations, or a producer and a class bean) share the required type and qualifiers. Also occurs at container init for programmatic lookup of a type satisfied by multiple beans.","commonSituations":"Adding a second implementation of an interface without @Alternative/@Named/@Unique qualifier; a library bean and an application bean both exposing the same API; upgrading a dependency that now registers an extra bean; forgetting to enable only one @Alternative.","solutions":["Add a distinguishing qualifier (@Named, custom @Qualifier) to the injection point or to one of the beans","Mark all but one of the conflicting beans @Alternative and enable exactly one in application.properties (quarkus.arc.selected-alternatives)","Use programmatic lookup: inject Instance<MyType> and call .select(qualifier).get()","Use @Priority or @Vetoed / remove the unwanted bean from discovery"],"exampleFix":"// before\n@Inject\nGreetingService service; // two implementations -> ambiguous\n\n// after\n@Inject\n@English\nGreetingService service; // qualifier disambiguates","handlingStrategy":"validation","validationCode":"Set<Bean<?>> beans = Arc.container().getBeans(MyType.class);\nif (beans.size() > 1) {\n    throw new IllegalStateException(\"Ambiguous beans for MyType: \" + beans);\n}","typeGuard":null,"tryCatchPattern":"try {\n    service = instance.select(qualifier).get();\n} catch (AmbiguousResolutionException e) {\n    LOGGER.errorf(\"Ambiguous beans: %s\", e.getMessage());\n    service = instance.select(qualifier, AdditionalQualifiers...).get();\n}","preventionTips":["Give every multi-implementation interface a dedicated @Qualifier","Audit beans exposing the same interface after adding dependencies","Prefer Instance<T> programmatic lookup when multiple implementations may exist","Enable exactly one @Alternative and verify with quarkus.arc.selected-alternatives"],"tags":["cdi","dependency-injection","ambiguous-resolution"],"backgroundTag":"ambiguous-bean-resolution","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}