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

  1. Use the fully-qualified class name (e.g. com.example.MyHostnameVerifier) in the property.
  2. Confirm the class's artifact is a runtime dependency of the application.
  3. In native mode, ensure the class is reachable (e.g. @RegisterForReflection or kept via runtime initialization) so it is present in the image.
  4. 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

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


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/1fbb8d028b6e3744. Report an issue: GitHub.