{"record":{"id":"afcb7117093f6ea7","repo":"quarkusio/quarkus","slug":"failed-to-instantiate-hostname-verifier-class-ve","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 (.+?)\\. Make sure it has a public, no-argument constructor","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientBase.java","lineNumber":161,"sourceCode":"            // If `verify-host` is disabled, we configure the client using the `NoopHostnameVerifier` verifier.\n            Optional<Boolean> verifyHost = oneOf(restClientConfig.verifyHost(), configRoot.verifyHost());\n            if (verifyHost.isPresent() && !verifyHost.get()) {\n                registerHostnameVerifier(NoopHostnameVerifier.class.getName(), builder);\n            }\n        }\n    }\n\n    private void registerHostnameVerifier(String verifier, RestClientBuilder 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, RestClientBuilder builder) {\n        try {\n            Optional<String> keyStoreType = oneOf(restClientConfig.keyStoreType(), configRoot.keyStoreType());\n            KeyStore keyStore = KeyStore.getInstance(keyStoreType.orElse(\"JKS\"));\n\n            Optional<String> keyStorePassword = oneOf(restClientConfig.keyStorePassword(), configRoot.keyStorePassword());\n            if (keyStorePassword.isEmpty()) {\n                throw new IllegalArgumentException(\"No password provided for keystore\");\n            }","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientBase.java#L143-L179","documentation":"The configured hostname verifier class was found and its public no-arg constructor was located, but instantiating it threw (InstantiationException, IllegalAccessException, or InvocationTargetException). The message tells the user to ensure the class has a public, no-argument constructor; the cause chain contains the real exception from the constructor body or access check.","triggerScenarios":"The verifier's constructor threw an exception (InvocationTargetException); the class is abstract or an interface (InstantiationException); the constructor is not accessible (IllegalAccessException, e.g. non-public constructor in another package).","commonSituations":"Constructor performs initialization that fails (missing config, IO errors); accidentally configuring an interface or abstract base class; non-public constructors in utility packages.","solutions":["Read the nested cause (e.getCause()) to see why the constructor failed","Make the class concrete with a public no-arg constructor whose body cannot fail at startup","Replace an abstract/interface entry with a concrete implementation class"],"exampleFix":"// before\npublic abstract class MyVerifier implements HostnameVerifier { ... }\n// after\npublic class MyVerifier implements HostnameVerifier {\n    public MyVerifier() {}\n    public boolean verify(String host, SSLSession s) { ... }\n}","handlingStrategy":"try-catch","validationCode":"Class<?> c = Class.forName(verifierName);\nif (java.lang.reflect.Modifier.isAbstract(c.getModifiers()) || c.isInterface()) {\n    throw new IllegalStateException(verifierName + \" is abstract/interface; cannot instantiate\");\n}","typeGuard":"static boolean isInstantiable(Class<?> c) {\n    return !c.isInterface() && !java.lang.reflect.Modifier.isAbstract(c.getModifiers())\n        && hasPublicNoArgCtor(c);\n}","tryCatchPattern":"try {\n    HostnameVerifier v = (HostnameVerifier) Class.forName(verifierName).getDeclaredConstructor().newInstance();\n} catch (ReflectiveOperationException e) {\n    log.error(\"Instantiate failed, cause: \" + e.getCause(), e.getCause());\n}","preventionTips":["Never configure abstract classes or interfaces as verifiers","Keep constructor bodies side-effect-free so startup instantiation can't fail","Inspect getCause() to find the exception thrown inside the constructor"],"tags":["restclient","ssl","reflection"],"backgroundTag":"class-instantiation-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}