2 Replies Latest reply on Nov 12, 2012 5:06 AM by hardy.ferentschik

    JSR-303 validated property 'password.confirmPassword' does not have a corresponding accessor for Spring data binding

    samwun9988

      Hi,

      With JBOSS 7.1.1, spring mvc 3.1.0.Final and Hibernate-validator-4.3.0.Final, I created a custom constrain validator for validating password and confirmPassword.

      When the validator get executed, it thrown the following exception:

       

       

      idator'

      22:47:32,874 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] (http--192.168.1.20-8080-5) Finished creating instance of bean 'deliveries.manager.validators.CompareStringsValidator'

      22:47:32,877 DEBUG [org.hibernate.validator.resourceloading.PlatformResourceBundleLocator] (http--192.168.1.20-8080-5) ValidationMessages not found.

      22:47:32,879 DEBUG [org.hibernate.validator.resourceloading.PlatformResourceBundleLocator] (http--192.168.1.20-8080-5) org.hibernate.validator.ValidationMessages found

      22:47:32,882 DEBUG [org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver] (http--192.168.1.20-8080-5) Resolving exception from handler [public java.lang.String deliveries.manager.controller.AdminSignUpController.submitProduct(javax.servlet.http.HttpServletRequest,org.springframework.ui.Model,deliveries.manager.pagebean.AdminSignupBean,org.springframework.validation.BindingResult,org.springframework.ui.ModelMap)]: java.lang.IllegalStateException: JSR-303 validated property 'password.confirmPassword' does not have a corresponding accessor for Spring data binding - check your DataBinder's configuration (bean property versus direct field access)

      22:47:32,885 DEBUG [org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver] (http--192.168.1.20-8080-5) Resolving exception from handler [public java.lang.String deliveries.manager.controller.AdminSignUpController.submitProduct(javax.servlet.http.HttpServletRequest,org.springframework.ui.Model,deliveries.manager.pagebean.AdminSignupBean,org.springframework.validation.BindingResult,org.springframework.ui.ModelMap)]: java.lang.IllegalStateException: JSR-303 validated property 'password.confirmPassword' does not have a corresponding accessor for Spring data binding - check your DataBinder's configuration (bean property versus direct field access)

      22:47:32,887 DEBUG [org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver] (http--192.168.1.20-8080-5) Resolving exception from handler [public java.lang.String deliveries.manager.controller.AdminSignUpController.submitProduct(javax.servlet.http.HttpServletRequest,org.springframework.ui.Model,deliveries.manager.pagebean.AdminSignupBean,org.springframework.validation.BindingResult,org.springframework.ui.ModelMap)]: java.lang.IllegalStateException: JSR-303 validated property 'password.confirmPassword' does not have a corresponding accessor for Spring data binding - check your DataBinder's configuration (bean property versus direct field access)

      22:47:32,889 DEBUG [org.springframework.web.servlet.DispatcherServlet] (http--192.168.1.20-8080-5) Could not complete request: java.lang.IllegalStateException: JSR-303 validated property 'password.confirmPassword' 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:148) [spring-context-3.1.0.RELEASE.jar:3.1.0.RELEASE]

              at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:101) [spring-context-3.1.0.RELEASE.jar:3.1.0.RELEASE]

              at org.springframework.validation.DataBinder.validate(DataBinder.java:722) [spring-context-3.1.0.RELEASE.jar:3.1.0.RELEASE]

              at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.validateIfApplicable(ModelAttributeMethodProcessor.java:154) [spring-web-3.1.0.RELEASE.jar:3.1.0.RELEASE]

              at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:107) [spring-web-3.1.0.RELEASE.jar:3.1.0.RELEASE]

              at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:74) [s

       

       

      Here is my bean class:

       

       

      @CompareStrings(propertyNames={"password", "confirmPassword"}, message="Password and Comfirm Password must be matched.")

      public class AdminSignupBean {

                private String password = "";

              private String confirmPassword = "";

       

       

      There is no password.confirmPassword defined in my bean.

      What might have gone wrong in my project/validator configuration?

       

      Your help is very much appreciated.

      Thanks

      Sam