{"record":{"id":"992f4dc41f35a423","repo":"quarkusio/quarkus","slug":"failed-to-instantiate-hostname-verifier-class","errorCode":null,"errorMessage":"Failed to instantiate hostname verifier class \" + verifier + \". Make sure it has a public, no-argument constructor","messagePattern":"Failed to instantiate hostname verifier class \" \\+ verifier \\+ \"\\. Make sure it has a public, no-argument constructor","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientCDIDelegateBuilder.java","lineNumber":296,"sourceCode":"        Optional<String> maybeHostnameVerifier = oneOf(restClientConfig.hostnameVerifier(), configRoot.hostnameVerifier());\n        if (maybeHostnameVerifier.isPresent()) {\n            registerHostnameVerifier(maybeHostnameVerifier.get(), builder);\n        }\n\n        oneOf(restClientConfig.verifyHost(), configRoot.verifyHost()).ifPresent(builder::verifyHost);\n    }\n\n    private void registerHostnameVerifier(String verifier, QuarkusRestClientBuilder builder) {\n        try {\n            Class<?> verifierClass = Thread.currentThread().getContextClassLoader().loadClass(verifier);\n            builder.hostnameVerifier((HostnameVerifier) verifierClass.getDeclaredConstructor().newInstance());\n        } catch (NoSuchMethodException e) {\n            throw new RuntimeException(\n                    \"Could not find a public, no-argument constructor for the hostname verifier class \" + verifier, e);\n        } catch (ClassNotFoundException e) {\n            throw new RuntimeException(\"Could not find hostname verifier class \" + verifier, e);\n        } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {\n            throw new RuntimeException(\n                    \"Failed to instantiate hostname verifier class \" + verifier\n                            + \". Make sure it has a public, no-argument constructor\",\n                    e);\n        } catch (ClassCastException e) {\n            throw new RuntimeException(\"The provided hostname verifier \" + verifier + \" is not an instance of HostnameVerifier\",\n                    e);\n        }\n    }\n\n    private void registerKeyStore(String keyStorePath, QuarkusRestClientBuilder builder) {\n        Optional<String> keyStorePassword = oneOf(restClientConfig.keyStorePassword(), configRoot.keyStorePassword());\n        Optional<String> keyStoreType = oneOf(restClientConfig.keyStoreType(), configRoot.keyStoreType());\n\n        try {\n            KeyStore keyStore = KeyStore.getInstance(keyStoreType.orElse(\"JKS\"));\n            if (keyStorePassword.isEmpty()) {\n                throw new IllegalArgumentException(\"No password provided for keystore\");\n            }","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientCDIDelegateBuilder.java#L278-L314","documentation":"After loading and constructing the configured hostname verifier, registerHostnameVerifier casts it to jakarta/javax.net.ssl.HostnameVerifier. If instantiation or access fails (InstantiationException, IllegalAccessException, InvocationTargetException — e.g. the constructor is non-public or throws), the exception is wrapped in this RuntimeException with guidance to provide a public no-arg constructor.","triggerScenarios":"Configured hostname-verifier class has a non-public no-arg constructor (InstantiationException/IllegalAccessException) or its constructor throws an exception during initialization.","commonSituations":"Package-private verifier class; constructor performing initialization that fails (throws IllegalStateException from within); inner (non-static) classes being instantiated reflectively.","solutions":["Make the class and its no-arg constructor public and the class static (if nested).","Fix or remove initialization logic in the constructor that throws.","If parameters are needed, register the verifier programmatically through the builder rather than via configuration."],"exampleFix":"// before\nclass MyVerifier implements HostnameVerifier { ... } // package-private\n\n// after\npublic class MyVerifier implements HostnameVerifier {\n    public MyVerifier() { }\n    ...\n}","handlingStrategy":"validation","validationCode":"Class<?> c = Class.forName(\"com.example.MyVerifier\");\nif (java.lang.reflect.Modifier.isAbstract(c.getModifiers()) || !java.lang.reflect.Modifier.isPublic(c.getModifiers())) {\n    throw new IllegalStateException(\"Verifier must be public and concrete\");\n}","typeGuard":"boolean publiclyInstantiable(Class<?> c) {\n    return java.lang.reflect.Modifier.isPublic(c.getModifiers())\n        && !java.lang.reflect.Modifier.isAbstract(c.getModifiers())\n        && hasPublicNoArgCtor(c);\n}","tryCatchPattern":"try {\n    // build client with configured verifier\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Failed to instantiate hostname verifier\")) {\n        builder.hostnameVerifier(new DefaultVerifier());\n    } else throw e;\n}","preventionTips":["Keep verifier constructors side-effect free so they cannot throw during init.","Make verifier classes public and static (never inner non-static classes).","Instantiate once in a test to catch init failures before deployment."],"tags":["tls","rest-client","reflection","configuration"],"backgroundTag":"missing-no-arg-constructor","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"}