{"record":{"id":"66ae83054c7691e7","repo":"quarkusio/quarkus","slug":"could-not-find-a-public-no-argument-constructor-f","errorCode":null,"errorMessage":"Could not find a public, no-argument constructor for the hostname verifier class ${verifier}","messagePattern":"Could not find a public, no-argument constructor for the hostname verifier class (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientBase.java","lineNumber":156,"sourceCode":"\n        Optional<String> hostnameVerifier = oneOf(restClientConfig.hostnameVerifier(), configRoot.hostnameVerifier());\n        if (hostnameVerifier.isPresent()) {\n            registerHostnameVerifier(hostnameVerifier.get(), builder);\n        } else {\n            // If `verify-host` is disabled, we configure the client using the `NoopHostnameVerifier` verifier.\n            Optional<Boolean> verifyHost = oneOf(restClientConfig.verifyHost(), configRoot.verifyHost());\n            if (verifyHost.isPresent() && !verifyHost.get()) {\n                registerHostnameVerifier(NoopHostnameVerifier.class.getName(), builder);\n            }\n        }\n    }\n\n    private void registerHostnameVerifier(String verifier, RestClientBuilder 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, RestClientBuilder builder) {\n        try {\n            Optional<String> keyStoreType = oneOf(restClientConfig.keyStoreType(), configRoot.keyStoreType());\n            KeyStore keyStore = KeyStore.getInstance(keyStoreType.orElse(\"JKS\"));","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/RestClientBase.java#L138-L174","documentation":"When quarkus.rest-client.*.hostname-verifier is configured, RestClientBase loads the named class and instantiates it via its no-argument constructor. This error is thrown when the class was found and loaded but has no public no-arg constructor (NoSuchMethodException from getDeclaredConstructor().newInstance()). The verifier must be a concrete class instantiable without arguments.","triggerScenarios":"Setting config property quarkus.rest-client.<name>.hostname-verifier (or rest client hostnameVerifier config) to a class that only defines parameterized constructors, or whose no-arg constructor is not public.","commonSituations":"Pointing the config at a verifier class that expects constructor dependencies (e.g. accepting an SSLContext); inner classes whose implicit constructor takes an enclosing instance; package-private constructors.","solutions":["Give the verifier class a public no-argument constructor","If constructor args are needed, instantiate it in code via builder.hostnameVerifier(...) instead of config","Ensure it's a top-level or static nested class, not an inner (non-static) class"],"exampleFix":"// before\nclass MyVerifier implements HostnameVerifier {\n    MyVerifier(SSLContext ctx) { ... }\n}\n// after\nclass MyVerifier implements HostnameVerifier {\n    public MyVerifier() { ... }\n    public boolean verify(String host, SSLSession session) { ... }\n}","handlingStrategy":"validation","validationCode":"Class<?> c = Thread.currentThread().getContextClassLoader().loadClass(verifierName);\nboolean ok = java.lang.reflect.Modifier.isPublic(c.getModifiers())\n    && Arrays.stream(c.getConstructors()).anyMatch(k -> k.getParameterCount() == 0);\nif (!ok) throw new IllegalStateException(verifierName + \" lacks a public no-arg constructor\");","typeGuard":"static boolean hasPublicNoArgCtor(Class<?> c) {\n    try { return c.getConstructor() != null && java.lang.reflect.Modifier.isPublic(c.getModifiers()); }\n    catch (NoSuchMethodException e) { return false; }\n}","tryCatchPattern":"try {\n    builder.hostnameVerifier((HostnameVerifier) Class.forName(verifierName).getDeclaredConstructor().newInstance());\n} catch (NoSuchMethodException e) {\n    throw new IllegalStateException(\"Verifier needs a public no-arg constructor: \" + verifierName, e);\n}","preventionTips":["Make verifier classes top-level (or static nested) with explicit public no-arg constructors","Avoid verifiers requiring constructor dependencies when configured via properties","Write a startup smoke test that instantiates every configured verifier class"],"tags":["restclient","ssl","reflection"],"backgroundTag":"missing-no-arg-constructor","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"}