quarkusio/quarkus · error · RuntimeException
The provided hostname verifier ${verifier} is not an instanc
Error message
The provided hostname verifier ${verifier} is not an instance of HostnameVerifier What it means
The class configured as hostname verifier loaded and instantiated fine, but the resulting object does not implement javax.net.ssl.HostnameVerifier, so the cast in registerHostnameVerifier failed with ClassCastException. The configured class must implement HostnameVerifier.
Source
Thrown at extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientBase.java:166
}
}
private void registerHostnameVerifier(String verifier, RestClientBuilder 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, RestClientBuilder builder) {
try {
Optional<String> keyStoreType = oneOf(restClientConfig.keyStoreType(), configRoot.keyStoreType());
KeyStore keyStore = KeyStore.getInstance(keyStoreType.orElse("JKS"));
Optional<String> keyStorePassword = oneOf(restClientConfig.keyStorePassword(), configRoot.keyStorePassword());
if (keyStorePassword.isEmpty()) {
throw new IllegalArgumentException("No password provided for keystore");
}
String password = keyStorePassword.get();
try (InputStream input = locateStream(keyStorePath)) {
keyStore.load(input, password.toCharArray());
} catch (IOException | CertificateException | NoSuchAlgorithmException e) {View on GitHub (pinned to e1c734241f)
Solutions
- Make the configured class implement javax.net.ssl.HostnameVerifier and its verify(String, SSLSession) method
- Check for import mistakes — implement javax.net.ssl.HostnameVerifier, not another HostnameVerifier type
- Verify the configured class name points at the intended verifier
Example fix
// before
import org.apache.http.conn.ssl.NoopHostnameVerifier;
public class MyVerifier extends NoopHostnameVerifier {}
// after
import javax.net.ssl.HostnameVerifier;
public class MyVerifier implements HostnameVerifier {
public boolean verify(String host, SSLSession session) { return true; }
} Defensive patterns
Strategy: type-guard
Validate before calling
Class<?> c = Class.forName(verifierName);
if (!javax.net.ssl.HostnameVerifier.class.isAssignableFrom(c)) {
throw new IllegalStateException(verifierName + " does not implement javax.net.ssl.HostnameVerifier");
} Type guard
static boolean isHostnameVerifier(Class<?> c) {
return javax.net.ssl.HostnameVerifier.class.isAssignableFrom(c);
} Try / catch
try {
Object o = Class.forName(verifierName).getDeclaredConstructor().newInstance();
if (!(o instanceof HostnameVerifier)) throw new IllegalStateException(verifierName + " is not a HostnameVerifier");
builder.hostnameVerifier((HostnameVerifier) o);
} catch (ClassCastException e) {
log.error("Wrong HostnameVerifier interface implemented", e);
} Prevention
- Import javax.net.ssl.HostnameVerifier exactly — beware same-named interfaces from other libraries
- Add an instanceof assert/unit test for every configured verifier
- Check implements clauses after refactors
When it happens
Trigger: Setting quarkus.rest-client.<name>.hostname-verifier to a class that implements a similarly-named but different interface, or an unrelated class entirely.
Common situations: Implementing the wrong HostnameVerifier (e.g. an application-specific interface of the same name); refactoring that changed the interface the class implements; copy-paste of a verifier from another library.
Related errors
- Could not find a public, no-argument constructor for the hos
- Could not find hostname verifier class ${verifier}
- Failed to instantiate hostname verifier class ${verifier}. M
- No password provided for keystore
- Failed to initialize trust store from classpath resource ${k
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/576b600686ad42c4.
Report an issue: GitHub.