quarkusio/quarkus · error · BeanNotFoundException

No matching bean in CDI context for type ${instance}

Error message

No matching bean in CDI context for type ${instance}

What it means

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.

Source

Thrown at extensions/hibernate-search-standalone-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/standalone/elasticsearch/runtime/bean/ArcBeanProvider.java:27

import io.quarkus.arc.ArcContainer;

public class ArcBeanProvider implements BeanProvider {
    private final ArcContainer delegate;

    public ArcBeanProvider(ArcContainer delegate) {
        this.delegate = delegate;
    }

    @Override
    public void close() {
        // Nothing to do
    }

    @Override
    public <T> BeanHolder<T> forType(Class<T> typeReference) {
        var instance = delegate.instance(typeReference);
        if (!instance.isAvailable()) {
            throw new BeanNotFoundException("No matching bean in CDI context for type " + instance);
        }
        return new ArcBeanHolder<>(instance);
    }

    @Override
    public <T> BeanHolder<T> forTypeAndName(Class<T> typeReference, String nameReference) {
        var instance = delegate.instance(typeReference, NamedLiteral.of(nameReference));
        if (!instance.isAvailable()) {
            throw new BeanNotFoundException(
                    "No matching bean in CDI context for type " + typeReference + " and @Named(" + nameReference + ")");
        }
        return new ArcBeanHolder<>(instance);
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Define a CDI bean of the requested type with a bean-defining annotation (e.g. @ApplicationScoped) so ArC discovers it.
  2. Check the exact class/type string in your quarkus.hibernate-search-standalone configuration for typos and ensure the type matches what the extension requests.
  3. Verify the module containing the bean is a bean archive (add META-INF/beans.xml with bean-discovery-mode=annotated or annotate the class).
  4. Confirm the Hibernate Search standalone extension is actually active (an entity/indexable setup) — its bean-producing build steps only run when activated.
  5. Catch BeanNotFoundException at startup and log the requested type to identify which configuration entry resolves to nothing.

Example fix

// before: class with no bean annotation, not discovered by ArC
public class MyMassIndexingObserver { ... }

// after
@ApplicationScoped
public class MyMassIndexingObserver { ... }
Defensive patterns

Strategy: validation

Validate before calling

// Startup sanity check before Hibernate Search beans are used
CDI.current().select(MyRequestedType.class).isResolvable(); // if false, forType() would throw
if (!Arc.container().select(MyRequestedType.class).isResolvable()) {
    throw new IllegalStateException("No CDI bean of type " + MyRequestedType.class + " — annotate it with @ApplicationScoped");
}

Type guard

public static <T> boolean hasCdiBean(Class<T> type) {
    return Arc.container() != null && Arc.container().select(type).isResolvable();
}

Try / catch

try {
    BeanHolder<T> holder = beanProvider.forType(MyType.class);
} catch (BeanNotFoundException e) {
    log.errorf("Missing CDI bean for %s: check @ApplicationScoped/qualifiers", MyType.class, e);
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/47faf711df9d5663. Report an issue: GitHub.