{"record":{"id":"47faf711df9d5663","repo":"quarkusio/quarkus","slug":"no-matching-bean-in-cdi-context-for-type-instanc","errorCode":null,"errorMessage":"No matching bean in CDI context for type ${instance}","messagePattern":"No matching bean in CDI context for type (.+?)","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":27,"sourceCode":"import io.quarkus.arc.ArcContainer;\n\npublic class ArcBeanProvider implements BeanProvider {\n    private final ArcContainer delegate;\n\n    public ArcBeanProvider(ArcContainer delegate) {\n        this.delegate = delegate;\n    }\n\n    @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":9,"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#L9-L42","documentation":"ArcBeanProvider.forType() adapts Quarkus ArC CDI lookups to Hibernate Search's bean API. It calls delegate.instance(typeReference) and, if no bean of the requested type is available in the CDI context, it throws BeanNotFoundException. This usually means Hibernate Search (standalone) was configured to use a CDI bean (e.g. a bean provider / mapper / multimap candidate) but no bean with that type is registered in the application.","triggerScenarios":"Calling forType(Class<T>) when the ArC container holds no bean assignable to typeReference, or the only matching beans are excluded (not discovered, wrong qualifiers, or the extension's bean-producing build steps did not run because Hibernate Search is not activated for the app).","commonSituations":"Referencing a custom mapper/bean by class name in quarkus.hibernate-search-standalone.* config while the bean lacks a scope/qualifier or is not annotated with a bean-defining annotation; typo in the configured class name; the bean lives in a library not indexed as a bean archive (no beans.xml / no @ApplicationScoped); removing a bean that Hibernate Search configuration still points to.","solutions":["Define a CDI bean of the requested type with a bean-defining annotation (e.g. @ApplicationScoped) so ArC discovers it.","Check the exact class/type string in your quarkus.hibernate-search-standalone configuration for typos and ensure the type matches what the extension requests.","Verify the module containing the bean is a bean archive (add META-INF/beans.xml with bean-discovery-mode=annotated or annotate the class).","Confirm the Hibernate Search standalone extension is actually active (an entity/indexable setup) — its bean-producing build steps only run when activated.","Catch BeanNotFoundException at startup and log the requested type to identify which configuration entry resolves to nothing."],"exampleFix":"// before: class with no bean annotation, not discovered by ArC\npublic class MyMassIndexingObserver { ... }\n\n// after\n@ApplicationScoped\npublic class MyMassIndexingObserver { ... }","handlingStrategy":"validation","validationCode":"// Startup sanity check before Hibernate Search beans are used\nCDI.current().select(MyRequestedType.class).isResolvable(); // if false, forType() would throw\nif (!Arc.container().select(MyRequestedType.class).isResolvable()) {\n    throw new IllegalStateException(\"No CDI bean of type \" + MyRequestedType.class + \" — annotate it with @ApplicationScoped\");\n}","typeGuard":"public static <T> boolean hasCdiBean(Class<T> type) {\n    return Arc.container() != null && Arc.container().select(type).isResolvable();\n}","tryCatchPattern":"try {\n    BeanHolder<T> holder = beanProvider.forType(MyType.class);\n} catch (BeanNotFoundException e) {\n    log.errorf(\"Missing CDI bean for %s: check @ApplicationScoped/qualifiers\", MyType.class, e);\n}","preventionTips":["Always give beans used by Hibernate Search a bean-defining annotation (@ApplicationScoped etc.).","Keep library beans in bean archives (beans.xml or annotated discovery).","After refactoring, grep quarkus.hibernate-search-standalone config for stale type names.","Run the app in dev mode early — Quarkus surfaces CDI resolution failures at startup."],"tags":["cdi","quarkus","hibernate-search","dependency-injection"],"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-12T22:17:10.623Z"}