quarkusio/quarkus · error · RuntimeException
Failed to instantiate hostname verifier class " + verifier +
Error message
Failed to instantiate hostname verifier class " + verifier + ". Make sure it has a public, no-argument constructor
What it means
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.
Source
Thrown at extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientCDIDelegateBuilder.java:296
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()) {
throw new IllegalArgumentException("No password provided for keystore");
}View on GitHub (pinned to e1c734241f)
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.
Example fix
// before
class MyVerifier implements HostnameVerifier { ... } // package-private
// after
public class MyVerifier implements HostnameVerifier {
public MyVerifier() { }
...
} Defensive patterns
Strategy: validation
Validate before calling
Class<?> c = Class.forName("com.example.MyVerifier");
if (java.lang.reflect.Modifier.isAbstract(c.getModifiers()) || !java.lang.reflect.Modifier.isPublic(c.getModifiers())) {
throw new IllegalStateException("Verifier must be public and concrete");
} Type guard
boolean publiclyInstantiable(Class<?> c) {
return java.lang.reflect.Modifier.isPublic(c.getModifiers())
&& !java.lang.reflect.Modifier.isAbstract(c.getModifiers())
&& hasPublicNoArgCtor(c);
} Try / catch
try {
// build client with configured verifier
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().contains("Failed to instantiate hostname verifier")) {
builder.hostnameVerifier(new DefaultVerifier());
} else throw e;
} Prevention
- 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.
When it happens
Trigger: Configured hostname-verifier class has a non-public no-arg constructor (InstantiationException/IllegalAccessException) or its constructor throws an exception during initialization.
Common situations: Package-private verifier class; constructor performing initialization that fails (throws IllegalStateException from within); inner (non-static) classes being instantiated reflectively.
Related errors
- Could not find a public, no-argument constructor for the hos
- Could not find 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/992f4dc41f35a423.
Report an issue: GitHub.