{"record":{"id":"efe51098c471ae16","repo":"quarkusio/quarkus","slug":"no-active-bean-found","errorCode":null,"errorMessage":"No active bean found","messagePattern":"No active bean found","errorType":"exception","errorClass":"UnsatisfiedResolutionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/runtime/src/main/java/io/quarkus/arc/InjectableInstance.java","lineNumber":99,"sourceCode":"     * @return the bean instance or {@code null}\n     */\n    default T orNull() {\n        return orElse(null);\n    }\n\n    /**\n     * Returns exactly one instance of an {@linkplain InjectableBean#checkActive() active} bean that matches\n     * the required type and qualifiers. If no active bean matches, or if more than one active bean matches,\n     * throws an exception.\n     *\n     * @return the single instance of an active matching bean\n     */\n    default T getActive() {\n        List<T> list = listActive();\n        if (list.size() == 1) {\n            return list.get(0);\n        } else if (list.isEmpty()) {\n            throw new UnsatisfiedResolutionException(\"No active bean found\");\n        } else {\n            throw new AmbiguousResolutionException(\"More than one active bean found: \" + list);\n        }\n    }\n\n    /**\n     * Returns the list of instances of {@linkplain InjectableBean#checkActive() active} beans that match\n     * the required type and qualifiers, sorter in priority order (higher priority goes first).\n     *\n     * @return the list of instances of matching active beans\n     */\n    default List<T> listActive() {\n        return handlesStream().filter(it -> it.getBean().isActive()).map(InstanceHandle::get).toList();\n    }\n}\n","sourceCodeStart":81,"sourceCodeEnd":115,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/InjectableInstance.java#L81-L115","documentation":"InjectableInstance.getActive() resolves the beans matching this instance, filters to those currently active, and requires exactly one match. It throws UnsatisfiedResolutionException('No active bean found') when zero beans are active, and AmbiguousResolutionException when more than one is — a way to get the single active contextual instance safely in Arc's hierarchical/conditional bean model.","triggerScenarios":"Calling getActive() on an InjectableInstance whose selection matches only beans that are currently inactive (e.g. disabled synthetic beans), or nothing at all, so listActive() returns an empty list.","commonSituations":"Using @InjectMock or conditional/synthetic beans that are deactivated by config; injecting an InjectableInstance for a bean excluded by profile or build property; code that assumes a bean exists but the application disabled it via quarkus config.","solutions":["Check why the bean is inactive: review quarkus.* config, profiles, and conditions that disable the synthetic bean, and enable it if needed.","Call listActive() and handle the empty case explicitly instead of getActive() when inactivity is a legitimate state.","Use getActive().get() alternatives like select() checks or Optional handling to fall back gracefully.","Verify the injection point's type/qualifiers actually match the intended bean."],"exampleFix":"// before\nFoo foo = instance.getActive(); // throws when inactive\n\n// after\nList<Foo> active = instance.listActive();\nFoo foo = active.isEmpty() ? Foo.DEFAULT : active.get(0);","handlingStrategy":"validation","validationCode":"List<Foo> active = instance.listActive();\nif (active.size() != 1) {\n    throw new IllegalStateException(\"Expected exactly 1 active bean, found \" + active.size());\n}","typeGuard":"static <T> Optional<T> activeIfUnique(InjectableInstance<T> i) {\n    List<T> l = i.listActive();\n    return l.size() == 1 ? Optional.of(l.get(0)) : Optional.empty();\n}","tryCatchPattern":"try {\n    return instance.getActive();\n} catch (UnsatisfiedResolutionException | AmbiguousResolutionException e) {\n    return fallbackInstance; // or rethrow with context about config/profile\n}","preventionTips":["Verify at startup that beans consumed via getActive() are not disabled by config or profiles.","Prefer listActive() + explicit handling when inactivity is a valid state.","Keep type/qualifier selection narrow enough that exactly one active bean matches."],"tags":["arc","cdi","dependency-injection","resolution","quarkus"],"backgroundTag":"no-active-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"}