{"record":{"id":"21aa657e3bf32a7b","repo":"spring-projects/spring-framework","slug":"invalid-property-propertyname-of-bean-class-21aa65","errorCode":null,"errorMessage":"Invalid property '{propertyName}' of bean class [{beanClass.getName()}]: Could not instantiate property type [{type.getName()}] to auto-grow nested property path","messagePattern":"Invalid property '(.+?)' of bean class \\[(.+?)\\]: Could not instantiate property type \\[(.+?)\\] to auto-grow nested property path","errorType":"exception","errorClass":"NullValueInNestedPathException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java","lineNumber":900,"sourceCode":"\t\t\t}\n\t\t\telse if (Collection.class.isAssignableFrom(type)) {\n\t\t\t\tTypeDescriptor elementDesc = (desc != null ? desc.getElementTypeDescriptor() : null);\n\t\t\t\treturn CollectionFactory.createCollection(type, (elementDesc != null ? elementDesc.getType() : null), 16);\n\t\t\t}\n\t\t\telse if (Map.class.isAssignableFrom(type)) {\n\t\t\t\tTypeDescriptor keyDesc = (desc != null ? desc.getMapKeyTypeDescriptor() : null);\n\t\t\t\treturn CollectionFactory.createMap(type, (keyDesc != null ? keyDesc.getType() : null), 16);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tConstructor<?> ctor = type.getDeclaredConstructor();\n\t\t\t\tif (Modifier.isPrivate(ctor.getModifiers())) {\n\t\t\t\t\tthrow new IllegalAccessException(\"Auto-growing not allowed with private constructor: \" + ctor);\n\t\t\t\t}\n\t\t\t\treturn BeanUtils.instantiateClass(ctor);\n\t\t\t}\n\t\t}\n\t\tcatch (Throwable ex) {\n\t\t\tthrow new NullValueInNestedPathException(getRootClass(), this.nestedPath + name,\n\t\t\t\t\t\"Could not instantiate property type [\" + type.getName() + \"] to auto-grow nested property path\", ex);\n\t\t}\n\t}\n\n\t/**\n\t * Create the array for the given array type.\n\t * @param arrayType the desired type of the target array\n\t * @return a new array instance\n\t */\n\tprivate static Object createArray(Class<?> arrayType) {\n\t\tAssert.notNull(arrayType, \"Array type must not be null\");\n\t\tClass<?> componentType = arrayType.componentType();\n\t\tif (componentType.isArray()) {\n\t\t\tObject array = Array.newInstance(componentType, 1);\n\t\t\tArray.set(array, 0, createArray(componentType));\n\t\t\treturn array;\n\t\t}\n\t\telse {","sourceCodeStart":882,"sourceCodeEnd":918,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java#L882-L918","documentation":"Thrown as NullValueInNestedPathException by newValue() at AbstractNestablePropertyAccessor.java:900 when auto-growing requires instantiating a default value for a nested property but BeanUtils.instantiateClass(ctor) (or array/collection creation) fails. The message names the target type that could not be instantiated. The catch is `catch (Throwable ex)`, so it also catches private-constructor IllegalAccessException raised earlier in newValue (line 894).","triggerScenarios":"Auto-grow (setAutoGrowNestedPaths true) traverses into a nested property whose declared type has no public/default no-arg constructor, is an interface/abstract type used as a field type, has a private constructor, or whose constructor throws on instantiation. Also fires if creating the array/Collection/Map via CollectionFactory fails.","commonSituations":"Declaring a nested field as an interface or abstract type (List vs ArrayList is fine, but a custom interface field type is not); nested type with only a required-args constructor; nested type that is an inner non-static class needing an enclosing instance; classpath/LinkageError while instantiating; Kotlin/record types without a usable canonical constructor.","solutions":["Change the nested field type to a concrete instantiable class with a no-arg constructor.","Add a public/protected no-arg constructor to the nested type (avoid private, which newValue explicitly rejects).","Make nested classes static (non-inner) so they can be instantiated without an enclosing instance.","If the type legitimately cannot be auto-instantiated, initialize it in the field declaration and turn off auto-grow for that path."],"exampleFix":"// before: interface field type, cannot be auto-grown\npublic class Order {\n    private Discount discount; // Discount is an interface\n}\n\n// after: concrete type with no-arg ctor\npublic class Order {\n    private PercentageDiscount discount = new PercentageDiscount();\n}","handlingStrategy":"validation","validationCode":"// Verify a nested type is concrete & instantiable before auto-growing\nClass<?> t = wrapper.getPropertyTypeDescriptor(\"nested\").getType();\nboolean ok = !t.isInterface() && !Modifier.isAbstract(t.getModifiers())\n    && !t.isPrimitive() && !t.isArray();\ntry { t.getDeclaredConstructor(); } catch (NoSuchMethodException e) { ok = false; }\nif (!ok) wrapper.setAutoGrowNestedPaths(false);","typeGuard":"static boolean instantiableNoArg(Class<?> t) {\n    if (t.isInterface() || Modifier.isAbstract(t.getModifiers())) return false;\n    try {\n        Constructor<?> c = t.getDeclaredConstructor();\n        return !Modifier.isPrivate(c.getModifiers());\n    } catch (NoSuchMethodException e) { return false; }\n}","tryCatchPattern":"try {\n    wrapper.setAutoGrowNestedPaths(true);\n    wrapper.getPropertyValue(\"nested.value\");\n} catch (NullValueInNestedPathException ex) {\n    if (ex.getCause() != null) {\n        // instantiation failed — type not usable for auto-grow\n        // initialize the field explicitly instead\n    }\n}","preventionTips":["Use concrete, non-abstract, non-interface field types for auto-grown paths.","Provide a non-private no-arg constructor on nested types.","Make nested classes static when they are inner classes.","Initialize complex nested objects manually instead of relying on auto-grow."],"tags":["spring-beans","beanwrapper","auto-grow","instantiation","nested-property"],"backgroundTag":null,"analyzedSha":"69bf83ad716d0cfc4b0520a19b4d8b24c79d1538","analyzedAt":"2026-08-09T15:32:58.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}