{"record":{"id":"2924d552304246c7","repo":"quarkusio/quarkus","slug":"no-matching-bean-in-cdi-context-for-type-typeref","errorCode":null,"errorMessage":"No matching bean in CDI context for type ${typeReference} and @Named(${nameReference})","messagePattern":"No matching bean in CDI context for type (.+?) and @Named\\((.+?)\\)","errorType":"exception","errorClass":"BeanNotFoundException","httpStatus":null,"severity":"error","filePath":"extensions/hibernate-search-standalone-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/runtime/bean/ArcBeanProvider.java","lineNumber":36,"sourceCode":"    @Override\n    public void close() {\n        // Nothing to do\n    }\n\n    @Override\n    public <T> BeanHolder<T> forType(Class<T> typeReference) {\n        var instance = delegate.instance(typeReference);\n        if (!instance.isAvailable()) {\n            throw new BeanNotFoundException(\"No matching bean in CDI context for type \" + instance);\n        }\n        return new ArcBeanHolder<>(instance);\n    }\n\n    @Override\n    public <T> BeanHolder<T> forTypeAndName(Class<T> typeReference, String nameReference) {\n        var instance = delegate.instance(typeReference, NamedLiteral.of(nameReference));\n        if (!instance.isAvailable()) {\n            throw new BeanNotFoundException(\n                    \"No matching bean in CDI context for type \" + typeReference + \" and @Named(\" + nameReference + \")\");\n        }\n        return new ArcBeanHolder<>(instance);\n    }\n}\n","sourceCodeStart":18,"sourceCodeEnd":42,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/hibernate-search-standalone-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/runtime/bean/ArcBeanProvider.java#L18-L42","documentation":"ArcBeanProvider.forTypeAndName() resolves a bean by type plus a @Named qualifier using NamedLiteral.of(nameReference). If ArC finds no bean matching both the type and the name, it throws BeanNotFoundException with the type and name in the message. This means the @Named value used in Hibernate Search configuration does not match any bean's @Named annotation.","triggerScenarios":"Calling forTypeAndName(Class<T>, String) where no bean of typeReference carries @Named(nameReference) — e.g. Hibernate Search config references a named bean that does not exist, or exists under a different name/type.","commonSituations":"Typo in the bean name in quarkus.hibernate-search-standalone.* properties; bean renamed during refactoring while config still references the old name; the bean has @Named on the wrong element or with different case (names are case-sensitive); the bean type was changed so it no longer matches.","solutions":["Add or correct @Named(nameReference) on the bean of the requested type so it matches the configured name exactly (case-sensitive).","Grep your configuration for the name value and fix typos or stale names after refactoring.","Ensure the bean is bean-defining (e.g. @ApplicationScoped + @Named) so ArC registers it.","Alternatively switch to nameless resolution (forType) if a unique bean of the type exists.","Catch BeanNotFoundException and print the requested type/name pair to pinpoint the mismatched config entry."],"exampleFix":"// before: name mismatch\n@ApplicationScoped\npublic class MyBean { ... }\n// config: ...bean-name=MyNamedBean\n\n// after\n@ApplicationScoped\n@Named(\"MyNamedBean\")\npublic class MyBean { ... }","handlingStrategy":"validation","validationCode":"// Verify a @Named bean of the right type exists before configuring it\nboolean ok = Arc.container().select(MyType.class, NamedLiteral.of(\"MyNamedBean\")).isResolvable();\nif (!ok) {\n    throw new IllegalStateException(\"No @Named(\\\"MyNamedBean\\\") bean of type \" + MyType.class);\n}","typeGuard":"public static <T> boolean hasNamedCdiBean(Class<T> type, String name) {\n    return Arc.container() != null\n        && Arc.container().select(type, NamedLiteral.of(name)).isResolvable();\n}","tryCatchPattern":"try {\n    BeanHolder<T> holder = beanProvider.forTypeAndName(MyType.class, \"MyNamedBean\");\n} catch (BeanNotFoundException e) {\n    log.errorf(\"No @Named bean for type=%s name=%s — fix @Named annotation or config value\", MyType.class, \"MyNamedBean\", e);\n}","preventionTips":["Keep bean names in a constants class shared between the @Named annotation and configuration.","Remember @Named values are case-sensitive — avoid ad-hoc string edits in properties.","Verify the bean has both a scope and @Named so it is bean-defining.","After renaming a bean, update every config reference to the old name."],"tags":["cdi","quarkus","hibernate-search","named-qualifier"],"backgroundTag":"missing-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"}