java.lang.IllegalStateException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Binding and validation work fine for nested fields even without getters and setters, but an exception is thrown when validation constraints are not met for nested fields. In this case when nested.number is greater than 5. {code:java} public class JavaBean { @Valid public NestedJavaBean nested; @Max(5) public Integer number; } public class NestedJavaBean { @NotNull @Max(5) public Integer number; } {code} {noformat} java.lang.IllegalStateException: JSR-303 validated property 'nested.number' does not have a corresponding accessor for Spring data binding - check your DataBinder's configuration (bean property versus direct field access) at org.springframework.validation.beanvalidation.SpringValidatorAdapter.processConstraintViolations(SpringValidatorAdapter.java:158) at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:107) at org.springframework.validation.DataBinder.validate(DataBinder.java:781) at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.validateIfApplicable(AbstractMessageConverterMethodArgumentResolver.java:188) at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:104) at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:77) .... Caused by: org.springframework.beans.NotReadablePropertyException: Invalid property 'nested' of bean class [org.springframework.samples.mvc.messageconverters.JavaBean]: Bean property 'nested' 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:731) at org.springframework.beans.BeanWrapperImpl.getNestedBeanWrapper(BeanWrapperImpl.java:572) at org.springframework.beans.BeanWrapperImpl.getBeanWrapperForPropertyPath(BeanWrapperImpl.java:549) at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:720) at org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:99) at org.springframework.validation.AbstractBindingResult.getRawFieldValue(AbstractBindingResult.java:283) at org.springframework.validation.beanvalidation.SpringValidatorAdapter.processConstraintViolations(SpringValidatorAdapter.java:143) {noformat}
    via by Tapio Koskinen,
  • Binding and validation work fine for nested fields even without getters and setters, but an exception is thrown when validation constraints are not met for nested fields. In this case when nested.number is greater than 5. {code:java} public class JavaBean { @Valid public NestedJavaBean nested; @Max(5) public Integer number; } public class NestedJavaBean { @NotNull @Max(5) public Integer number; } {code} {noformat} java.lang.IllegalStateException: JSR-303 validated property 'nested.number' does not have a corresponding accessor for Spring data binding - check your DataBinder's configuration (bean property versus direct field access) at org.springframework.validation.beanvalidation.SpringValidatorAdapter.processConstraintViolations(SpringValidatorAdapter.java:158) at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:107) at org.springframework.validation.DataBinder.validate(DataBinder.java:781) at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.validateIfApplicable(AbstractMessageConverterMethodArgumentResolver.java:188) at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:104) at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:77) .... Caused by: org.springframework.beans.NotReadablePropertyException: Invalid property 'nested' of bean class [org.springframework.samples.mvc.messageconverters.JavaBean]: Bean property 'nested' 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:731) at org.springframework.beans.BeanWrapperImpl.getNestedBeanWrapper(BeanWrapperImpl.java:572) at org.springframework.beans.BeanWrapperImpl.getBeanWrapperForPropertyPath(BeanWrapperImpl.java:549) at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:720) at org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:99) at org.springframework.validation.AbstractBindingResult.getRawFieldValue(AbstractBindingResult.java:283) at org.springframework.validation.beanvalidation.SpringValidatorAdapter.processConstraintViolations(SpringValidatorAdapter.java:143) {noformat}
    via by Tapio Koskinen,
    • java.lang.IllegalStateException: JSR-303 validated property 'nested.number' does not have a corresponding accessor for Spring data binding - check your DataBinder's configuration (bean property versus direct field access) at org.springframework.validation.beanvalidation.SpringValidatorAdapter.processConstraintViolations(SpringValidatorAdapter.java:158) at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:107) at org.springframework.validation.DataBinder.validate(DataBinder.java:781) at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.validateIfApplicable(AbstractMessageConverterMethodArgumentResolver.java:188) at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:104) at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:77)
    No Bugmate found.