Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-10243

GenericConversionService.convert() throws IllegalArgumentException after updating to Spring 3.2.1

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 3.2.1
    • Fix Version/s: 3.2.2
    • Component/s: None

      Description

      After updating Spring from 3.2.0.RELEASE to 3.2.1.RELEASE I've got following error:

      [skip]
      java.lang.IllegalArgumentException: The source to convert from must be an instance of @org.hibernate.validator.constraints.NotEmpty @javax.validation.constraints.Size @javax.validation.constraints.Pattern java.lang.String; instead it was a ru.mystamps.web.model.ActivateAccountForm
          at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:164)
          at org.springframework.validation.AbstractPropertyBindingResult.formatFieldValue(AbstractPropertyBindingResult.java:125)
          at org.springframework.validation.AbstractBindingResult.getFieldValue(AbstractBindingResult.java:222)
          at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:120)
          at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:179)
          at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:199)
          at org.springframework.web.servlet.tags.form.LabelTag.autogenerateFor(LabelTag.java:130)
          at org.springframework.web.servlet.tags.form.LabelTag.resolveFor(LabelTag.java:120)
          at org.springframework.web.servlet.tags.form.LabelTag.writeTagContent(LabelTag.java:90)
          at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:103)
          at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80)
          at org.apache.jsp.WEB_002dINF.tiles.body.account.activate_jsp._jspx_meth_form_label_2(activate_jsp.java:667)
          at org.apache.jsp.WEB_002dINF.tiles.body.account.activate_jsp._jspService(activate_jsp.java:224)
      [skip]
      

      JSP code:

      <form:form method="post" action="${activateUrl}" modelAttribute="activateAccountForm">
          <form:label path="login">
              <spring:message code="t_login" />
          </form:label>
          ...
      </form:form>
      

      Model declaration:

      public class ActivateAccountForm implements ActivateAccountDto {                                    
      
          @NotEmpty(groups = Login1Checks.class)                                                          
          @Size.List({                                                                                    
              @Size(                                                                                      
                  min = ValidationRules.LOGIN_MIN_LENGTH,                                                 
                  message = "{value.too-short}",                                                          
                  groups = Login2Checks.class                                                             
              ),                                                                                          
              @Size(                                                                                      
                  max = ValidationRules.LOGIN_MAX_LENGTH,                                                 
                  message = "{value.too-long}",                                                           
                  groups = Login2Checks.class                                                             
              )                                                                                           
          })                                                                                              
          @Pattern(                                                                                       
              regexp = ValidationRules.LOGIN_REGEXP,                                                      
              message = "{login.invalid}",                                                                
              groups = Login3Checks.class                                                                 
          )                                                                                               
          @UniqueLogin(groups = Login4Checks.class)                                                       
          private String login;
      
          ...
      }
      

      Controller:

      @RequestMapping(value = Url.ACTIVATE_ACCOUNT_PAGE, method = RequestMethod.POST)                 
      public String processActivationForm(                                                            
          @Validated({                                                                                
              LoginChecks.class, NameChecks.class, PasswordChecks.class,                              
              PasswordConfirmationChecks.class, ActKeyChecks.class, FormChecks.class                  
          }) ActivateAccountForm form, BindingResult result) {                                        
      
          if (result.hasErrors()) {                                                                   
              return null;                                                                            
          }                                                                                           
      
          userService.registerUser(form);                                                             
      
          return "redirect:" + Url.SUCCESSFUL_ACTIVATION_PAGE;                                        
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              pwebb Phil Webb
              Last updater:
              Spring Issues Spring Issues
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                3 years, 24 weeks, 5 days ago