{"record":{"id":"c0c7f7386c582de2","repo":"quarkusio/quarkus","slug":"unable-to-instantiate-service-providerclass-usi","errorCode":null,"errorMessage":"Unable to instantiate service ${providerClass} using the no-arg constructor.","messagePattern":"Unable to instantiate service (.+?) using the no-arg constructor\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/smallrye-health/runtime/src/main/java/io/quarkus/smallrye/health/runtime/SmallRyeHealthRecorder.java","lineNumber":37,"sourceCode":"import io.vertx.ext.web.RoutingContext;\n\n@Recorder\npublic class SmallRyeHealthRecorder {\n    private final SmallRyeHealthBuildFixedConfig buildFixedConfig;\n    private final RuntimeValue<SmallRyeHealthRuntimeConfig> runtimeConfig;\n\n    public SmallRyeHealthRecorder(\n            final SmallRyeHealthBuildFixedConfig buildFixedConfig,\n            final RuntimeValue<SmallRyeHealthRuntimeConfig> runtimeConfig) {\n        this.buildFixedConfig = buildFixedConfig;\n        this.runtimeConfig = runtimeConfig;\n    }\n\n    public void registerHealthCheckResponseProvider(Class<? extends HealthCheckResponseProvider> providerClass) {\n        try {\n            HealthCheckResponse.setResponseProvider(providerClass.getConstructor().newInstance());\n        } catch (Exception e) {\n            throw new IllegalStateException(\n                    \"Unable to instantiate service \" + providerClass + \" using the no-arg constructor.\");\n        }\n    }\n\n    public Handler<RoutingContext> uiHandler(String healthUiFinalDestination, String healthUiPath,\n            List<FileSystemStaticHandler.StaticWebRootConfiguration> webRootConfigurations, ShutdownContext shutdownContext) {\n\n        if (runtimeConfig.getValue().enabled()) {\n            WebJarStaticHandler handler = new WebJarStaticHandler(healthUiFinalDestination, healthUiPath,\n                    webRootConfigurations);\n            shutdownContext.addShutdownTask(new ShutdownContext.CloseRunnable(handler));\n            return handler;\n        } else {\n            return new WebJarNotFoundHandler();\n        }\n    }\n\n    public void processSmallRyeHealthRuntimeConfiguration() {","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/smallrye-health/runtime/src/main/java/io/quarkus/smallrye/health/runtime/SmallRyeHealthRecorder.java#L19-L55","documentation":"At runtime the health recorder instantiates the selected HealthCheckResponseProvider via its public no-arg constructor and installs it into HealthCheckResponse.setResponseProvider. Any failure from getConstructor()/newInstance() (missing public no-arg ctor, inaccessible class, throwing constructor) is swallowed and rethrown as this IllegalStateException — the original cause is not attached.","triggerScenarios":"registerHealthCheckResponseProvider is called with a provider class that has no public no-arg constructor, is not accessible, or whose constructor throws — commonly a custom HealthCheckResponseProvider implementation.","commonSituations":"Writing a custom provider with constructor parameters; provider class made package-private; constructor performing initialization that fails (e.g. CDI lookups before the container is ready); class visibility restricted by the Quarkus classloader.","solutions":["Give the provider a public no-arg constructor and move initialization out of the constructor","Make the provider class public (and its constructor public)","Ensure the constructor does not throw; lazy-init dependencies inside the methods","If the provider is not yours, register the standard SmallRye provider instead"],"exampleFix":"// before\npublic class MyProvider implements HealthCheckResponseProvider {\n    private final Service svc;\n    public MyProvider(Service svc) { this.svc = svc; } // no no-arg ctor\n}\n\n// after\npublic class MyProvider implements HealthCheckResponseProvider {\n    public MyProvider() { }\n    @Override\n    public HealthCheckResponseBuilder createResponseBuilder() {\n        return new MyBuilder(ServiceLocator.getInstance()); // lazy lookup\n    }\n}","handlingStrategy":"validation","validationCode":"Class<?> c = MyProvider.class;\nif (java.util.Arrays.stream(c.getConstructors())\n        .noneMatch(k -> k.getParameterCount() == 0)) {\n    throw new IllegalStateException(c.getName() + \" needs a public no-arg constructor\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    providerClass.getConstructor().newInstance();\n} catch (ReflectiveOperationException e) {\n    throw new IllegalStateException(\"Provider \" + providerClass + \" must be public with a working no-arg ctor\", e);\n}","preventionTips":["Always implement ServiceLoader-style providers with a public no-arg constructor","Keep constructors side-effect free","Make provider classes public","Unit-test instantiation of any class you register as a provider"],"tags":["health","reflection","instantiation","quarkus"],"backgroundTag":"service-instantiation-failed","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"}