spring-projects/spring-framework · error · InvalidPropertyException
Illegal attempt to get property '${actualName}' threw except
Error message
Illegal attempt to get property '${actualName}' threw exception What it means
Catch-all block in getPropertyValue(PropertyTokenHolder) for any Exception not matched by the earlier, more specific catches. Spring wraps it as InvalidPropertyException 'Illegal attempt to get property ... threw exception'. Seeing this (rather than the InvocationTargetException variant) means the failure happened outside the reflective getter call itself, for example inside Spring's own value-processing or argument conversion.
Source
Thrown at spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java:699
return value;
}
catch (InvalidPropertyException ex) {
throw ex;
}
catch (IndexOutOfBoundsException ex) {
throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,
"Index of out of bounds in property path '" + propertyName + "'", ex);
}
catch (NumberFormatException | TypeMismatchException ex) {
throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,
"Invalid index in property path '" + propertyName + "'", ex);
}
catch (InvocationTargetException ex) {
throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,
"Getter for property '" + actualName + "' threw exception", ex);
}
catch (Exception ex) {
throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,
"Illegal attempt to get property '" + actualName + "' threw exception", ex);
}
}
/**
* Return the {@link PropertyHandler} for the specified {@code propertyName}, navigating
* if necessary. Return {@code null} if not found rather than throwing an exception.
* @param propertyName the property to obtain the descriptor for
* @return the property descriptor for the specified property,
* or {@code null} if not found
* @throws BeansException in case of introspection failure
*/
protected @Nullable PropertyHandler getPropertyHandler(String propertyName) throws BeansException {
Assert.notNull(propertyName, "Property name must not be null");
AbstractNestablePropertyAccessor nestedPa = getPropertyAccessorForPropertyPath(propertyName);
return nestedPa.getLocalPropertyHandler(getFinalPath(nestedPa, propertyName));
}View on GitHub (pinned to e8729d0438)
Solutions
- Read the exception's cause to locate the original failure and fix it at the source.
- If using a custom PropertyHandler, ensure its getValue() only throws InvocationTargetException for target failures.
- Verify reflection access is permitted (module opens / no SecurityManager blocking).
- Reproduce with debug logging on org.springframework.beans to capture the underlying cause.
Example fix
// before
@Override public Object getValue() throws Exception {
if (cached == null) throw new IllegalStateException("not initialized");
return cached;
}
// after
@Override public Object getValue() throws Exception {
if (cached == null) cached = compute(); // initialize lazily instead of throwing
return cached;
} Defensive patterns
Strategy: try-catch
Validate before calling
// Validate custom PropertyHandler.getValue() does not throw non-InvocationTargetException; // ensure module opens the package to spring-beans before access.
Type guard
static boolean canReflectivelyAccess(Class<?> bean) {
return bean.getModule().isOpen(bean.getPackageName(), BeanWrapper.class.getModule());
} Try / catch
try {
Object v = wrapper.getPropertyValue(propertyName);
} catch (InvalidPropertyException ex) {
Throwable cause = ex.getCause();
// classify and handle (security, illegal state, custom handler bug)
} Prevention
- Custom PropertyHandler implementations should wrap target exceptions in InvocationTargetException.
- Open the bean's package to spring-beans on the module path.
- Enable debug logging on org.springframework.beans to capture the underlying cause.
When it happens
Trigger: An IllegalStateException or IllegalArgumentException raised while preparing arguments for ph.getValue(); a security/PrivilegedAction failure during getter access; a custom PropertyHandler subclass whose getValue() throws a non-InvocationTargetException.
Common situations: Custom BeanWrapper subclasses/PropertyHandler implementations that throw; security-manager restrictions on reflection; Spring internal failures during resolvable-type resolution; edge cases in Groovy-generated methods.
Related errors
- Bean property '{propertyName}' is not readable or has an inv
- Getter for property '${actualName}' threw exception
- Nested property in path '{propertyName}' does not exist
- No property handler found
- Invalid array index in property path '{tokens.canonicalName}
AI-assisted analysis of spring-projects/spring-framework@e8729d0438 (2026-08-04).
Data as JSON: /data/errors/849d2c09f3cdfc2b.json.
Report an issue: GitHub.