{"record":{"id":"86853c067003d59d","repo":"quarkusio/quarkus","slug":"failed-to-instantiate-the-http-client-options","errorCode":null,"errorMessage":"Failed to instantiate the HTTP client options \" + httpClientOptionsClass + \". Make sure the bean is properly configured for CDI injection.","messagePattern":"Failed to instantiate the HTTP client options \" \\+ httpClientOptionsClass \\+ \"\\. Make sure the bean is properly configured for CDI injection\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientBuilderImpl.java","lineNumber":327,"sourceCode":"        this.disableDefaultMapper = disableDefaultMapper;\n        return this;\n    }\n\n    public RestClientBuilderImpl enableCompression(boolean enableCompression) {\n        this.enableCompression = enableCompression;\n        return this;\n    }\n\n    public RestClientBuilderImpl domainSocket(String path) {\n        this.domainSocketPath = path;\n        return this;\n    }\n\n    @Override\n    public RestClientBuilderImpl httpClientOptions(Class<? extends HttpClientOptions> httpClientOptionsClass) {\n        HttpClientOptions bean = BeanGrabber.getBeanIfDefined(httpClientOptionsClass);\n        if (bean == null) {\n            throw new IllegalArgumentException(\"Failed to instantiate the HTTP client options \" + httpClientOptionsClass\n                    + \". Make sure the bean is properly configured for CDI injection.\");\n        }\n\n        return httpClientOptions(bean);\n    }\n\n    @Override\n    public RestClientBuilderImpl httpClientOptions(HttpClientOptions httpClientOptions) {\n        register(new HttpClientOptionsContextResolver(httpClientOptions));\n        return this;\n    }\n\n    public RestClientBuilderImpl clientOptionsCustomizer(Consumer<HttpClientOptions> clientOptionsCustomizer) {\n        clientBuilder.clientOptionsCustomizer(clientOptionsCustomizer);\n        return this;\n    }\n\n    @Override","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientBuilderImpl.java#L309-L345","documentation":"RestClientBuilderImpl.httpClientOptions(Class) resolves an HttpClientOptions instance from the CDI container via BeanGrabber.getBeanIfDefined. When the container has no bean for that class, it throws this IllegalArgumentException. Quarkus only injects beans that are discoverable CDI beans (e.g. annotated @ApplicationScoped or registered via @Unremovable), so an unmanaged or removed class cannot be resolved.","triggerScenarios":"Calling QuarkusRestClientBuilder.httpClientOptions(SomeHttpClientOptions.class) where SomeHttpClientOptions has no CDI bean definition, or the bean exists but was removed as unused during build-time augmentation.","commonSituations":"Passing a plain class (no bean-defining annotation) as the options class; the options class being in a package excluded from bean discovery; ArC removing the bean as @Unremovable-less unused bean; running outside a Quarkus runtime where CDI is absent.","solutions":["Annotate the HttpClientOptions implementation with a bean-defining annotation such as @ApplicationScoped (and import io.vertx.axle/core HttpClientOptions class you intend).","If ArC removes the bean as unused, annotate it with @io.quarkus.arc.Unremovable.","Register the bean programmatically if it cannot carry annotations (e.g. via an @ApplicationRoot-scoped producing @Produces method).","Alternatively pass an already-constructed HttpClientOptions instance using the httpClientOptions(HttpClientOptions instance) overload instead of the class-based one."],"exampleFix":"// before\npublic class MyHttpClientOptions extends HttpClientOptions { ... }\nbuilder.httpClientOptions(MyHttpClientOptions.class); // IllegalArgumentException\n\n// after\n@ApplicationScoped\n@Unremovable\npublic class MyHttpClientOptions extends HttpClientOptions { ... }\nbuilder.httpClientOptions(MyHttpClientOptions.class); // resolves via CDI","handlingStrategy":"validation","validationCode":"HttpClientOptions opts = BeanGrabber.getBeanIfDefined(MyHttpClientOptions.class); // or check with Arc.container().instance(MyHttpClientOptions.class).isAvailable() before calling builder.httpClientOptions(MyHttpClientOptions.class)","typeGuard":"boolean isCdiBean(Class<?> c) { return java.util.Optional.ofNullable(io.quarkus.arc.Arc.container())\n        .map(a -> a.instance(c).isAvailable()).orElse(false); }","tryCatchPattern":"try {\n    builder.httpClientOptions(MyOptions.class);\n} catch (IllegalArgumentException e) {\n    // fall back to default options or instance overload\n    builder.httpClientOptions(new MyOptions());\n}","preventionTips":["Always add @ApplicationScoped (and @Unremovable if ArC pruning is a risk) to options classes passed by Class.","Prefer the instance-based httpClientOptions(HttpClientOptions) overload when CDI wiring is uncertain.","Verify bean availability in an integration test at startup."],"tags":["cdi","rest-client","quarkus","configuration"],"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"}