org.springframework.beans.NotReadablePropertyException: Invalid property 'slave1[0].slave1[0]' of bean class [Master]: Bean property 'slave1[0].slave1[0]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?

Spring JIRA | pascal gehl | 10 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    I have the following object graph : Master has a collection of Slave1 which in turn has a collection of Slave2 objects. Master XML validation has : <property name="slave1" cascade="true"/> Slave1 xml validation has : <property name="slave2" cascade="true"/> Slave2 xml validation has : <property name="name"> <not-blank/> </property> When the name property of Slave2 validation fails I have the following exception : org.springframework.beans.NotReadablePropertyException: Invalid property 'slave1[0].slave1[0]' of bean class [Master]: Bean property 'slave1[0].slave1[0]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:508) at org.springframework.beans.BeanWrapperImpl.getNestedBeanWrapper(BeanWrapperImpl.java:415) at org.springframework.beans.BeanWrapperImpl.getBeanWrapperForPropertyPath(BeanWrapperImpl.java:392) at org.springframework.beans.BeanWrapperImpl.getBeanWrapperForPropertyPath(BeanWrapperImpl.java:393) at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:498) at org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:77) at org.springframework.validation.AbstractBindingResult.rejectValue(AbstractBindingResult.java:177) at org.springmodules.validation.bean.BeanValidator.applyGlobalValidationRules(BeanValidator.java:368) at org.springmodules.validation.bean.BeanValidator.applyBeanValidation(BeanValidator.java:331) at org.springmodules.validation.bean.BeanValidator.validateObjectGraphConstraints(BeanValidator.java:168) at org.springmodules.validation.bean.BeanValidator.validateListOrSetProperty(BeanValidator.java:266) at org.springmodules.validation.bean.BeanValidator.validateObjectGraphConstraints(BeanValidator.java:200) at org.springmodules.validation.bean.BeanValidator.validateListOrSetProperty(BeanValidator.java:266) at org.springmodules.validation.bean.BeanValidator.validateObjectGraphConstraints(BeanValidator.java:200) at org.springmodules.validation.bean.BeanValidator.validate(BeanValidator.java:97) After investigation I found that the problem comes from the following piece of code in BeanValidator.applyGlobalValidationRules() method : String nestedPath = errors.getNestedPath(); String propertyName = nestedPath.substring(0, nestedPath.length() - 1); errors.popNestedPath(); errors.rejectValue(propertyName, errorCode, rule.getErrorArguments(obj), rule.getDefaultErrorMessage()); errors.pushNestedPath(propertyName); In my case the propertyName is equal to slave1[0].slave2[0] and after popping the nested path is equal to slave1[0]. in errors.rejectValue() (implemented by Spring's AbstractBindingResult) the propertyName gets prefixed by the nested path leading to "slave1[0].slave1[0].slave2[0]" giving me the exception mentioned before. I propose to fix this in removing the nested path from the propertyName prior to call rejectValue().

    Spring JIRA | 10 years ago | pascal gehl
    org.springframework.beans.NotReadablePropertyException: Invalid property 'slave1[0].slave1[0]' of bean class [Master]: Bean property 'slave1[0].slave1[0]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
  2. 0

    I have the following object graph : Master has a collection of Slave1 which in turn has a collection of Slave2 objects. Master XML validation has : <property name="slave1" cascade="true"/> Slave1 xml validation has : <property name="slave2" cascade="true"/> Slave2 xml validation has : <property name="name"> <not-blank/> </property> When the name property of Slave2 validation fails I have the following exception : org.springframework.beans.NotReadablePropertyException: Invalid property 'slave1[0].slave1[0]' of bean class [Master]: Bean property 'slave1[0].slave1[0]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:508) at org.springframework.beans.BeanWrapperImpl.getNestedBeanWrapper(BeanWrapperImpl.java:415) at org.springframework.beans.BeanWrapperImpl.getBeanWrapperForPropertyPath(BeanWrapperImpl.java:392) at org.springframework.beans.BeanWrapperImpl.getBeanWrapperForPropertyPath(BeanWrapperImpl.java:393) at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:498) at org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:77) at org.springframework.validation.AbstractBindingResult.rejectValue(AbstractBindingResult.java:177) at org.springmodules.validation.bean.BeanValidator.applyGlobalValidationRules(BeanValidator.java:368) at org.springmodules.validation.bean.BeanValidator.applyBeanValidation(BeanValidator.java:331) at org.springmodules.validation.bean.BeanValidator.validateObjectGraphConstraints(BeanValidator.java:168) at org.springmodules.validation.bean.BeanValidator.validateListOrSetProperty(BeanValidator.java:266) at org.springmodules.validation.bean.BeanValidator.validateObjectGraphConstraints(BeanValidator.java:200) at org.springmodules.validation.bean.BeanValidator.validateListOrSetProperty(BeanValidator.java:266) at org.springmodules.validation.bean.BeanValidator.validateObjectGraphConstraints(BeanValidator.java:200) at org.springmodules.validation.bean.BeanValidator.validate(BeanValidator.java:97) After investigation I found that the problem comes from the following piece of code in BeanValidator.applyGlobalValidationRules() method : String nestedPath = errors.getNestedPath(); String propertyName = nestedPath.substring(0, nestedPath.length() - 1); errors.popNestedPath(); errors.rejectValue(propertyName, errorCode, rule.getErrorArguments(obj), rule.getDefaultErrorMessage()); errors.pushNestedPath(propertyName); In my case the propertyName is equal to slave1[0].slave2[0] and after popping the nested path is equal to slave1[0]. in errors.rejectValue() (implemented by Spring's AbstractBindingResult) the propertyName gets prefixed by the nested path leading to "slave1[0].slave1[0].slave2[0]" giving me the exception mentioned before. I propose to fix this in removing the nested path from the propertyName prior to call rejectValue().

    Spring JIRA | 10 years ago | pascal gehl
    org.springframework.beans.NotReadablePropertyException: Invalid property 'slave1[0].slave1[0]' of bean class [Master]: Bean property 'slave1[0].slave1[0]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
  3. 0

    I Keep getting 'NotReadablePropertyException' when running a unit test against a new Spring Validator class

    Stack Overflow | 3 years ago | Sudhir
    org.springframework.beans.NotReadablePropertyException: Invalid property 'login' of bean class [springapp.service.LoginValidator]: Bean property 'login' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Create User Exception on Snapshot

    GitHub | 3 years ago | bryanhelmig
    org.springframework.beans.NotReadablePropertyException: Invalid property 'email' of bean class [org.graylog2.restclient.models.api.requests.CreateUserRequestForm]: Bean property 'email' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
  6. 0

    org.springframework.beans.NotReadablePropertyException: Invalid property. Bean property is not readable or has an invalid getter method

    Stack Overflow | 2 years ago | masterdany88
    play.api.Application$$anon$1: Execution exception[[IllegalStateException: JSR-303 validated property 'customer' does not have a corresponding accessor for data binding - check your DataBinder's configuration (bean property versus direct field access)]]

  1. treefolk 5 times, last 2 months ago
  2. abrazeneb 7 times, last 8 months ago
11 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. org.springframework.beans.NotReadablePropertyException

    Invalid property 'slave1[0].slave1[0]' of bean class [Master]: Bean property 'slave1[0].slave1[0]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?

    at org.springframework.beans.BeanWrapperImpl.getPropertyValue()
  2. Spring Beans
    BeanWrapperImpl.getPropertyValue
    1. org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:508)
    2. org.springframework.beans.BeanWrapperImpl.getNestedBeanWrapper(BeanWrapperImpl.java:415)
    3. org.springframework.beans.BeanWrapperImpl.getBeanWrapperForPropertyPath(BeanWrapperImpl.java:392)
    4. org.springframework.beans.BeanWrapperImpl.getBeanWrapperForPropertyPath(BeanWrapperImpl.java:393)
    5. org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:498)
    5 frames
  3. Spring Context
    AbstractBindingResult.rejectValue
    1. org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:77)
    2. org.springframework.validation.AbstractBindingResult.rejectValue(AbstractBindingResult.java:177)
    2 frames
  4. org.springmodules.validation
    BeanValidator.validate
    1. org.springmodules.validation.bean.BeanValidator.applyGlobalValidationRules(BeanValidator.java:368)
    2. org.springmodules.validation.bean.BeanValidator.applyBeanValidation(BeanValidator.java:331)
    3. org.springmodules.validation.bean.BeanValidator.validateObjectGraphConstraints(BeanValidator.java:168)
    4. org.springmodules.validation.bean.BeanValidator.validateListOrSetProperty(BeanValidator.java:266)
    5. org.springmodules.validation.bean.BeanValidator.validateObjectGraphConstraints(BeanValidator.java:200)
    6. org.springmodules.validation.bean.BeanValidator.validateListOrSetProperty(BeanValidator.java:266)
    7. org.springmodules.validation.bean.BeanValidator.validateObjectGraphConstraints(BeanValidator.java:200)
    8. org.springmodules.validation.bean.BeanValidator.validate(BeanValidator.java:97)
    8 frames