{"record":{"id":"2929a5c838dff1bb","repo":"quarkusio/quarkus","slug":"could-not-find-a-public-no-argument-constructor-f-2929a5","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 \" \\+ verifier","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientCDIDelegateBuilder.java","lineNumber":291,"sourceCode":"        Optional<String> maybeKeyStore = oneOf(restClientConfig.keyStore(), configRoot.keyStore());\n        if (maybeKeyStore.isPresent() && !maybeKeyStore.get().isBlank() && !NONE.equals(maybeKeyStore.get())) {\n            registerKeyStore(maybeKeyStore.get(), builder);\n        }\n\n        Optional<String> maybeHostnameVerifier = oneOf(restClientConfig.hostnameVerifier(), configRoot.hostnameVerifier());\n        if (maybeHostnameVerifier.isPresent()) {\n            registerHostnameVerifier(maybeHostnameVerifier.get(), builder);\n        }\n\n        oneOf(restClientConfig.verifyHost(), configRoot.verifyHost()).ifPresent(builder::verifyHost);\n    }\n\n    private void registerHostnameVerifier(String verifier, QuarkusRestClientBuilder 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, QuarkusRestClientBuilder builder) {\n        Optional<String> keyStorePassword = oneOf(restClientConfig.keyStorePassword(), configRoot.keyStorePassword());\n        Optional<String> keyStoreType = oneOf(restClientConfig.keyStoreType(), configRoot.keyStoreType());\n","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientCDIDelegateBuilder.java#L273-L309","documentation":"When TLS is configured via properties, registerHostnameVerifier loads the configured hostname verifier class by name and instantiates it with its public no-arg constructor. If the class has no such constructor, a NoSuchMethodException is wrapped in this RuntimeException. Only the constructor lookup fails here — class loading and casting failures get their own messages.","triggerScenarios":"Setting quarkus.rest-client.<key>.hostname-verifier (or TLS configuration trust/hostname-verifier property) to a class whose constructor is private, takes arguments, or is inherited/non-public.","commonSituations":"Pointing the property at a verifier requiring constructor parameters; a nested/inner class implicitly non-static or with an implicit non-public constructor; copy-pasting a verifier from another framework that used DI.","solutions":["Give the HostnameVerifier implementation a public no-argument constructor (make it a public top-level or static nested class).","Verify the property value is the fully-qualified class name of the right class.","If construction needs parameters, instantiate it programmatically via the builder instead of through the property."],"exampleFix":"// before\npublic class MyVerifier implements HostnameVerifier {\n    private MyVerifier() { } // no public ctor\n}\n\n// after\npublic class MyVerifier implements HostnameVerifier {\n    public MyVerifier() { }\n    public boolean verify(String hostname, SSLSession session) { ... }\n}","handlingStrategy":"validation","validationCode":"Class<?> c = Class.forName(\"com.example.MyVerifier\", true, Thread.currentThread().getContextClassLoader());\nif (c.getDeclaredConstructor() == null || !java.lang.reflect.Modifier.isPublic(c.getDeclaredConstructor().getModifiers())) {\n    throw new IllegalStateException(\"Hostname verifier needs a public no-arg constructor\");\n}","typeGuard":"boolean hasPublicNoArgCtor(Class<?> c) {\n    try { return java.lang.reflect.Modifier.isPublic(c.getDeclaredConstructor().getModifiers()); }\n    catch (NoSuchMethodException e) { return false; }\n}","tryCatchPattern":"try {\n    // build client with the configured hostname verifier\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"no-argument constructor\")) {\n        builder.hostnameVerifier((h, s) -> true); // fallback verifier\n    } else throw e;\n}","preventionTips":["Make hostname verifiers public top-level (or static nested) classes with public no-arg constructors.","Verify the class can be instantiated in a plain unit test before wiring via properties.","Use programmatic builder.hostnameVerifier(...) when construction needs parameters."],"tags":["tls","rest-client","reflection","configuration"],"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-14T00:17:10.932Z"}