{"record":{"id":"1fbb8d028b6e3744","repo":"quarkusio/quarkus","slug":"could-not-find-hostname-verifier-class-verifie","errorCode":null,"errorMessage":"Could not find hostname verifier class \" + verifier","messagePattern":"Could not find hostname verifier class \" \\+ verifier","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":294,"sourceCode":"        }\n\n        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()) {","sourceCodeStart":276,"sourceCodeEnd":312,"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#L276-L312","documentation":"registerHostnameVerifier uses the thread context classloader to load the configured hostname verifier class name. A ClassNotFoundException is wrapped in this RuntimeException, meaning the class name in the configuration does not resolve on the current classpath. This indicates a naming or packaging problem, not a code defect in the verifier itself.","triggerScenarios":"Setting the hostname-verifier config property to a class name that is misspelled, uses a wrong package, or whose jar/module is not on the runtime classpath (especially in native mode where the class was not registered for reflection/inclusion).","commonSituations":"Typo or wrong package in application.properties; dependency containing the verifier missing at runtime; Quarkus native image excluding the class; using the simple class name instead of the fully-qualified name.","solutions":["Use the fully-qualified class name (e.g. com.example.MyHostnameVerifier) in the property.","Confirm the class's artifact is a runtime dependency of the application.","In native mode, ensure the class is reachable (e.g. @RegisterForReflection or kept via runtime initialization) so it is present in the image.","Print/verify Thread.currentThread().getContextClassLoader().loadClass(name) works in the same context."],"exampleFix":"// before (application.properties)\nquarkus.rest-client.my-client.hostname-verifier=MyVerifier\n\n// after\nquarkus.rest-client.my-client.hostname-verifier=com.example.security.MyHostnameVerifier","handlingStrategy":"validation","validationCode":"String fqn = \"com.example.MyVerifier\";\ntry { Class.forName(fqn, false, Thread.currentThread().getContextClassLoader()); }\ncatch (ClassNotFoundException e) { throw new IllegalStateException(\"Verifier class not on runtime classpath: \" + fqn); }","typeGuard":"boolean classOnClasspath(String name) {\n    try { Thread.currentThread().getContextClassLoader().loadClass(name); return true; }\n    catch (ClassNotFoundException e) { return false; }\n}","tryCatchPattern":"try {\n    // build client with configured verifier\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Could not find hostname verifier class\")) {\n        builder.hostnameVerifier(new DefaultVerifier()); // safe fallback\n    } else throw e;\n}","preventionTips":["Use fully-qualified class names in hostname-verifier properties.","Ensure the artifact containing the verifier is a runtime dependency.","In native mode, confirm the class ships in the image (reflection/runtime init config)."],"tags":["tls","classpath","configuration","rest-client"],"backgroundTag":"class-not-found","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"}