quarkusio/quarkus · error · RuntimeException
Could not find hostname verifier class " + verifier
Error message
Could not find hostname verifier class " + verifier
What it means
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.
Source
Thrown at extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientCDIDelegateBuilder.java:294
}
Optional<String> maybeHostnameVerifier = oneOf(restClientConfig.hostnameVerifier(), configRoot.hostnameVerifier());
if (maybeHostnameVerifier.isPresent()) {
registerHostnameVerifier(maybeHostnameVerifier.get(), builder);
}
oneOf(restClientConfig.verifyHost(), configRoot.verifyHost()).ifPresent(builder::verifyHost);
}
private void registerHostnameVerifier(String verifier, QuarkusRestClientBuilder builder) {
try {
Class<?> verifierClass = Thread.currentThread().getContextClassLoader().loadClass(verifier);
builder.hostnameVerifier((HostnameVerifier) verifierClass.getDeclaredConstructor().newInstance());
} catch (NoSuchMethodException e) {
throw new RuntimeException(
"Could not find a public, no-argument constructor for the hostname verifier class " + verifier, e);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Could not find hostname verifier class " + verifier, e);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(
"Failed to instantiate hostname verifier class " + verifier
+ ". Make sure it has a public, no-argument constructor",
e);
} catch (ClassCastException e) {
throw new RuntimeException("The provided hostname verifier " + verifier + " is not an instance of HostnameVerifier",
e);
}
}
private void registerKeyStore(String keyStorePath, QuarkusRestClientBuilder builder) {
Optional<String> keyStorePassword = oneOf(restClientConfig.keyStorePassword(), configRoot.keyStorePassword());
Optional<String> keyStoreType = oneOf(restClientConfig.keyStoreType(), configRoot.keyStoreType());
try {
KeyStore keyStore = KeyStore.getInstance(keyStoreType.orElse("JKS"));
if (keyStorePassword.isEmpty()) {View on GitHub (pinned to e1c734241f)
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.
Example fix
// before (application.properties) quarkus.rest-client.my-client.hostname-verifier=MyVerifier // after quarkus.rest-client.my-client.hostname-verifier=com.example.security.MyHostnameVerifier
Defensive patterns
Strategy: validation
Validate before calling
String fqn = "com.example.MyVerifier";
try { Class.forName(fqn, false, Thread.currentThread().getContextClassLoader()); }
catch (ClassNotFoundException e) { throw new IllegalStateException("Verifier class not on runtime classpath: " + fqn); } Type guard
boolean classOnClasspath(String name) {
try { Thread.currentThread().getContextClassLoader().loadClass(name); return true; }
catch (ClassNotFoundException e) { return false; }
} Try / catch
try {
// build client with configured verifier
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Could not find hostname verifier class")) {
builder.hostnameVerifier(new DefaultVerifier()); // safe fallback
} else throw e;
} Prevention
- 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).
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Could not find a public, no-argument constructor for the hos
- Failed to instantiate hostname verifier class " + verifier +
- The provided hostname verifier " + verifier + " is not an in
- No password provided for keystore
- Failed to initialize trust store from classpath resource " +
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/1fbb8d028b6e3744.
Report an issue: GitHub.