{"id":"849d2c09f3cdfc2b","repo":"spring-projects/spring-framework","slug":"illegal-attempt-to-get-property-actualname-th","errorCode":null,"errorMessage":"Illegal attempt to get property '${actualName}' threw exception","messagePattern":"Illegal attempt to get property '(.+?)' threw exception","errorType":"exception","errorClass":"InvalidPropertyException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java","lineNumber":699,"sourceCode":"\t\t\treturn value;\n\t\t}\n\t\tcatch (InvalidPropertyException ex) {\n\t\t\tthrow ex;\n\t\t}\n\t\tcatch (IndexOutOfBoundsException ex) {\n\t\t\tthrow new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,\n\t\t\t\t\t\"Index of out of bounds in property path '\" + propertyName + \"'\", ex);\n\t\t}\n\t\tcatch (NumberFormatException | TypeMismatchException ex) {\n\t\t\tthrow new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,\n\t\t\t\t\t\"Invalid index in property path '\" + propertyName + \"'\", ex);\n\t\t}\n\t\tcatch (InvocationTargetException ex) {\n\t\t\tthrow new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,\n\t\t\t\t\t\"Getter for property '\" + actualName + \"' threw exception\", ex);\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tthrow new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,\n\t\t\t\t\t\"Illegal attempt to get property '\" + actualName + \"' threw exception\", ex);\n\t\t}\n\t}\n\n\n\t/**\n\t * Return the {@link PropertyHandler} for the specified {@code propertyName}, navigating\n\t * if necessary. Return {@code null} if not found rather than throwing an exception.\n\t * @param propertyName the property to obtain the descriptor for\n\t * @return the property descriptor for the specified property,\n\t * or {@code null} if not found\n\t * @throws BeansException in case of introspection failure\n\t */\n\tprotected @Nullable PropertyHandler getPropertyHandler(String propertyName) throws BeansException {\n\t\tAssert.notNull(propertyName, \"Property name must not be null\");\n\t\tAbstractNestablePropertyAccessor nestedPa = getPropertyAccessorForPropertyPath(propertyName);\n\t\treturn nestedPa.getLocalPropertyHandler(getFinalPath(nestedPa, propertyName));\n\t}","sourceCodeStart":681,"sourceCodeEnd":717,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/e8729d043887bf0d0baf91e062e909b56eb2b708/spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java#L681-L717","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n@Override public Object getValue() throws Exception {\n    if (cached == null) throw new IllegalStateException(\"not initialized\");\n    return cached;\n}\n\n// after\n@Override public Object getValue() throws Exception {\n    if (cached == null) cached = compute(); // initialize lazily instead of throwing\n    return cached;\n}","handlingStrategy":"try-catch","validationCode":"// Validate custom PropertyHandler.getValue() does not throw non-InvocationTargetException;\n// ensure module opens the package to spring-beans before access.","typeGuard":"static boolean canReflectivelyAccess(Class<?> bean) {\n    return bean.getModule().isOpen(bean.getPackageName(), BeanWrapper.class.getModule());\n}","tryCatchPattern":"try {\n    Object v = wrapper.getPropertyValue(propertyName);\n} catch (InvalidPropertyException ex) {\n    Throwable cause = ex.getCause();\n    // classify and handle (security, illegal state, custom handler bug)\n}","preventionTips":["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."],"tags":["spring-beans","bean-wrapper","getter","catch-all","illegal-access"],"analyzedSha":"e8729d043887bf0d0baf91e062e909b56eb2b708","analyzedAt":"2026-08-04T19:07:39.725Z","schemaVersion":2}