{"record":{"id":"6574d834c06a6f53","repo":"quarkusio/quarkus","slug":"multiple-beans-with-type-type-getname-found","errorCode":null,"errorMessage":"multiple beans with type + type.getName() + found for TLS configuration + bucketName","messagePattern":"multiple beans with type \\+ type\\.getName\\(\\) \\+ found for TLS configuration \\+ bucketName","errorType":"exception","errorClass":"AmbiguousResolutionException","httpStatus":null,"severity":"error","filePath":"extensions/tls-registry/runtime/src/main/java/io/quarkus/tls/runtime/CertificateRecorder.java","lineNumber":250,"sourceCode":"            @Override\n            public TlsConfigurationRegistry get() {\n                return CertificateRecorder.this;\n            }\n        };\n    }\n\n    public void register(String name, Supplier<TlsConfiguration> supplier) {\n        register(name, supplier.get());\n    }\n\n    static <T> InstanceHandle<T> lookupProvider(Class<T> type, String bucketName) {\n        var container = Arc.container();\n        var qualifier = TlsConfig.DEFAULT_NAME.equals(bucketName)\n                ? Default.Literal.INSTANCE\n                : Identifier.Literal.of(bucketName);\n        var instances = container.listAll(type, qualifier);\n        if (instances.size() > 1) {\n            throw new AmbiguousResolutionException(\n                    \"multiple beans with type \" + type.getName() + \" found for TLS configuration \" + bucketName);\n        }\n        if (instances.isEmpty()) {\n            return new InstanceHandle<T>() {\n                @Override\n                public T get() {\n                    return null;\n                }\n            };\n        }\n        return instances.get(0);\n    }\n\n    static <T> InstanceHandle<T> lookupFactory(Class<T> type, String typeName) {\n        var container = Arc.container();\n        var qualifier = Identifier.Literal.of(typeName);\n        var instances = container.listAll(type, qualifier);\n        if (instances.size() > 1) {","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/tls-registry/runtime/src/main/java/io/quarkus/tls/runtime/CertificateRecorder.java#L232-L268","documentation":"TLS keystore/truststore providers are resolved from the CDI container by type plus Identifier qualifier (the TLS configuration name, or @Default for 'default'). If more than one bean of the requested provider type (e.g. KeystoreProvider/TrustStoreProvider) matches the same configuration name, the resolution is ambiguous and Arc cannot choose, so lookupProvider throws AmbiguousResolutionException.","triggerScenarios":"Two beans implementing the same provider type annotated @Identifier(\"<name>\") (or both @Default for the default bucket) exist in the container and getKeyStore/getTrustStore calls lookupProvider for that name.","commonSituations":"Registering a custom KeystoreProvider/TrustStoreProvider with @Identifier(\"default\") while the built-in ones are also active; accidentally duplicating a provider bean in a library and an application; renaming a configuration bucket so two providers now share one identifier.","solutions":["Make the bean unique: remove or de-duplicate one of the conflicting provider beans so only one remains per type + identifier.","Change the @Identifier qualifier on your custom provider to a distinct TLS configuration name and reference that name via tls.*-tls-configuration-name.","If you must ship a replacement for the default, mark the built-in bean unremovable duplicates carefully — instead exclude the conflicting provider (e.g. via @ExcludeBean or removing the library dependency)."],"exampleFix":"// before\n@ApplicationScoped\n@Identifier(\"default\")\nclass MyKeyStoreProvider implements KeystoreProvider { ... }\n// after\n@ApplicationScoped\n@Identifier(\"my-app-ssl\")\nclass MyKeyStoreProvider implements KeystoreProvider { ... }\n// and set quarkus.tls.key-store-provider / tls.my-app-ssl references accordingly","handlingStrategy":"validation","validationCode":"List<InstanceHandle<KeystoreProvider>> existing = Arc.container()\n    .listAll(KeystoreProvider.class, Identifier.Literal.of(\"my-app-ssl\"));\nif (existing.size() > 1) {\n    throw new IllegalStateException(\"Duplicate KeystoreProvider beans for identifier 'my-app-ssl'\");\n}","typeGuard":"boolean hasUniqueProvider(Class<?> type, String bucketName) {\n    var qualifier = TlsConfig.DEFAULT_NAME.equals(bucketName)\n        ? Default.Literal.INSTANCE : Identifier.Literal.of(bucketName);\n    return Arc.container().listAll(type, qualifier).size() == 1;\n}","tryCatchPattern":"try {\n    TlsConfiguration cfg = registry.get(\"my-app-ssl\");\n    // use cfg\n} catch (AmbiguousResolutionException e) {\n    log.error(\"Multiple provider beans for this TLS config; check @Identifier qualifiers\", e);\n}","preventionTips":["Use unique @Identifier values matching your tls.*-tls-configuration-name exactly.","Do not annotate custom providers with @Identifier(\"default\") unless intentionally replacing built-ins (and understand the collision risk).","Grep your classpath/dependencies for duplicate provider implementations before adding a new one."],"tags":["cdi","quarkus","ambiguous-bean","tls"],"backgroundTag":"ambiguous-cdi-bean","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}