spring-projects/spring-framework · error · NullValueInNestedPathException
Invalid property '{propertyName}' of bean class [{beanClass.
Error message
Invalid property '{propertyName}' of bean class [{beanClass.getName()}]: Could not determine property type for auto-growing a default value What it means
Thrown as NullValueInNestedPathException by createDefaultPropertyValue at AbstractNestablePropertyAccessor.java:871 when auto-grow is enabled but getPropertyTypeDescriptor() returns null for the property, so Spring cannot determine which class to instantiate as the default value. It is purely an auto-grow configuration/introspection failure, not a null data problem.
Source
Thrown at spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java:871
if (logger.isTraceEnabled()) {
logger.trace("Using cached nested property accessor for property '" + canonicalName + "'");
}
}
return nestedPa;
}
private Object setDefaultValue(PropertyTokenHolder tokens) {
PropertyValue pv = createDefaultPropertyValue(tokens);
setPropertyValue(tokens, pv);
Object defaultValue = getPropertyValue(tokens);
Assert.state(defaultValue != null, "Default value must not be null");
return defaultValue;
}
private PropertyValue createDefaultPropertyValue(PropertyTokenHolder tokens) {
TypeDescriptor desc = getPropertyTypeDescriptor(tokens.canonicalName);
if (desc == null) {
throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + tokens.canonicalName,
"Could not determine property type for auto-growing a default value");
}
Object defaultValue = newValue(desc.getType(), desc, tokens.canonicalName);
return new PropertyValue(tokens.canonicalName, defaultValue);
}
private Object newValue(Class<?> type, @Nullable TypeDescriptor desc, String name) {
try {
if (type.isArray()) {
return createArray(type);
}
else if (Collection.class.isAssignableFrom(type)) {
TypeDescriptor elementDesc = (desc != null ? desc.getElementTypeDescriptor() : null);
return CollectionFactory.createCollection(type, (elementDesc != null ? elementDesc.getType() : null), 16);
}
else if (Map.class.isAssignableFrom(type)) {
TypeDescriptor keyDesc = (desc != null ? desc.getMapKeyTypeDescriptor() : null);
return CollectionFactory.createMap(type, (keyDesc != null ? keyDesc.getType() : null), 16);View on GitHub (pinned to 69bf83ad71)
Solutions
- Disable auto-grow for that path or give the property a concrete declared type with proper getter/setter.
- Add explicit getter/setter and field type so getPropertyTypeDescriptor resolves to a real class.
- Pre-initialize the nested object yourself instead of relying on auto-grow.
- Register a custom property editor / ConversionService if the type is non-standard.
Example fix
// before: auto-grow cannot infer type private Object details; wrapper.setAutoGrowNestedPaths(true); // after: concrete, introspectable type private Details details = new Details();
Defensive patterns
Strategy: validation
Validate before calling
// Only enable auto-grow for fully introspectable types
BeanWrapper w = new BeanWrapperImpl(target);
if (w.getPropertyTypeDescriptor("details") != null) {
w.setAutoGrowNestedPaths(true);
} else {
// initialize manually; do not rely on auto-grow
((MyBean) target).setDetails(new Details());
} Type guard
static boolean autoGrowSafe(BeanWrapper w, String path) {
return w.getPropertyTypeDescriptor(path) != null;
} Try / catch
try {
wrapper.setAutoGrowNestedPaths(true);
wrapper.getPropertyValue("details.x");
} catch (NullValueInNestedPathException ex) {
if (ex.getMessage().contains("Could not determine property type")) {
// not a data problem: introspect the type manually
throw new IllegalStateException("cannot auto-grow " + ex.getPropertyName(), ex);
}
throw ex;
} Prevention
- Ensure auto-grown properties have concrete declared types with getters/setters.
- Prefer explicit initialization over auto-grow for non-introspectable types.
- Test auto-grow against each nested type in a unit test.
- Avoid Object/Map-typed fields where you expect auto-grow to materialize a bean.
When it happens
Trigger: setAutoGrowNestedPaths(true) is set, then a nested path is traversed whose target property has no readable/writable accessor and no resolvable TypeDescriptor (e.g. a property that exists only as a Map/Collection index with no generic info, or a synthetic property the BeanWrapper cannot introspect). getPropertyTypeDescriptor returns null and setDefaultValue is invoked.
Common situations: Auto-growing into an untyped Map/Object property; binding against a dynamic bean with no proper getters/setters; auto-growing a property whose declaring class has reflection issues (introspection partially failed); misconfigured @ConfigurationProperties with auto-grow on a field Spring cannot introspect.
Related errors
- Invalid property '{propertyName}' of bean class [{beanClass.
- Invalid property '{propertyName}' of bean class [{beanClass.
- Nested property in path '{propertyName}' does not exist
- Cannot access indexed value in property referenced in indexe
- Invalid property '{propertyName}' of bean class [{beanClass.
AI-assisted analysis of spring-projects/spring-framework@69bf83ad71 (2026-08-09).
Data as JSON: /api/errors/6bc7bdbfa830b611.
Report an issue: GitHub.