{"record":{"id":"7994c235ddc5dd9a","repo":"quarkusio/quarkus","slug":"class-s-which-is-used-as-s-in-class-s-must","errorCode":null,"errorMessage":"Class '%s' which is used as %s in class '%s' must have a no-args constructor","messagePattern":"Class '(.+?)' which is used as (.+?) in class '(.+?)' must have a no-args constructor","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/spring-boot-properties/deployment/src/main/java/io/quarkus/spring/boot/properties/deployment/YamlListObjectHandler.java","lineNumber":206,"sourceCode":"                            b.invokeVirtual(\n                                    MethodDesc.of(HashMap.class, \"put\", Object.class, Object.class, Object.class),\n                                    resultHandle, Const.of(entry.getKey()), Const.of(entry.getValue()));\n                        }\n                        b.return_(resultHandle);\n                    });\n                });\n            }\n        });\n    }\n\n    private void validateClass(ClassInfo classInfo, Member member) {\n        if (Modifier.isInterface(classInfo.flags())) {\n            throw new IllegalArgumentException(\n                    \"The use of interfaces as the generic type of Lists fields / methods is not allowed. Offending field is '\"\n                            + member.name() + \"' of class '\" + member.declaringClass().name().toString() + \"'\");\n        }\n        if (!classInfo.hasNoArgsConstructor()) {\n            throw new IllegalArgumentException(\n                    String.format(\"Class '%s' which is used as %s in class '%s' must have a no-args constructor\", classInfo,\n                            member.phraseUsage(), member.declaringClass().name().toString()));\n        }\n        if (!Modifier.isPublic(classInfo.flags())) {\n            throw new IllegalArgumentException(\n                    String.format(\"Class '%s' which is used as %s in class '%s' must be a public class\", classInfo,\n                            member.phraseUsage(), member.declaringClass().name().toString()));\n        }\n    }\n\n    private ClassInfo validateType(Type type) {\n        if (type.kind() != Type.Kind.PARAMETERIZED_TYPE) {\n            throw new IllegalArgumentException(ILLEGAL_ARGUMENT_MESSAGE);\n        }\n        ParameterizedType parameterizedType = (ParameterizedType) type;\n        if (!DotNames.LIST.equals(parameterizedType.name())) {\n            throw new IllegalArgumentException(ILLEGAL_ARGUMENT_MESSAGE);\n        }","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/spring-boot-properties/deployment/src/main/java/io/quarkus/spring/boot/properties/deployment/YamlListObjectHandler.java#L188-L224","documentation":"List-of-object YAML config binding instantiates each element via its no-arg constructor. If the element class lacks a no-args constructor, Quarkus cannot create instances and deployment fails with IllegalArgumentException.","triggerScenarios":"A List<SomeClass> config member whose SomeClass has only constructors with parameters (e.g. required-args or builder-only style) processed by YamlListObjectHandler.","commonSituations":"Immutable config objects with constructor initialization, records-like patterns, or classes generated by Lombok @AllArgsConstructor without @NoArgsConstructor.","solutions":["Add a public no-args constructor to the element class","Use Lombok @NoArgsConstructor alongside the other constructors","Switch to standard Quarkus @ConfigMapping interface binding, which does not require a no-args constructor"],"exampleFix":"// before\npublic class ServerConfig { private final String host; public ServerConfig(String host){...} }\n// after\npublic class ServerConfig { public ServerConfig(){} public ServerConfig(String host){...} }","handlingStrategy":"validation","validationCode":"static void requireNoArgsConstructor(Class<?> c) {\n    try { c.getDeclaredConstructor(); }\n    catch (NoSuchMethodException e) { throw new IllegalStateException(c + \" needs a public no-args constructor for YAML config binding\"); }\n}","typeGuard":"boolean isInstantiableForConfig(Class<?> c) {\n    try { c.getDeclaredConstructor(); return java.lang.reflect.Modifier.isPublic(c.getModifiers()); }\n    catch (NoSuchMethodException e) { return false; }\n}","tryCatchPattern":"catch (IllegalArgumentException e) { if (e.getMessage().contains(\"no-args constructor\")) { /* add no-args ctor */ } throw e; }","preventionTips":["Always give config POJOs a public no-args constructor","Pair Lombok @AllArgsConstructor with @NoArgsConstructor","Prefer @ConfigMapping interfaces which avoid instantiation requirements"],"tags":["quarkus","yaml","config","constructor"],"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"}