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

Spring JIRA | Phil Webb | 4 years ago
  1. 0

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

    Stack Overflow | 4 years ago | Slava Semushin
    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
  2. 0

    After updating Spring from 3.2.0.RELEASE to 3.2.1.RELEASE I've got following error: {noformat} [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] {noformat} JSP code: {code:xml} <form:form method="post" action="${activateUrl}" modelAttribute="activateAccountForm"> <form:label path="login"> <spring:message code="t_login" /> </form:label> ... </form:form> {code} Model declaration: {code:java} 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; ... } {code} Controller: {code:java} @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; } {code}

    Spring JIRA | 4 years ago | Phil Webb
    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
  3. 0

    After updating Spring from 3.2.0.RELEASE to 3.2.1.RELEASE I've got following error: {noformat} [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] {noformat} JSP code: {code:xml} <form:form method="post" action="${activateUrl}" modelAttribute="activateAccountForm"> <form:label path="login"> <spring:message code="t_login" /> </form:label> ... </form:form> {code} Model declaration: {code:java} 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; ... } {code} Controller: {code:java} @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; } {code}

    Spring JIRA | 4 years ago | Phil Webb
    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
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    [SPR-6350] Converting from String to Properties with leading/trailing whitespace results in ConversionFailedException - Spring JIRA

    spring.io | 1 year ago
    java.lang.IllegalArgumentException: Invalid String property ' '; properties should be in the format name=value
  6. 0

    ControllerLinkBuilder throws exception when target method has a generic parameter

    GitHub | 10 months ago | elennick
    java.lang.IllegalArgumentException: source must be [null] if sourceType == [null]

    2 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. 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()
    2. Spring Core
      GenericConversionService.convert
      1. org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:164)
      1 frame
    3. Spring Context
      AbstractBindingResult.getFieldValue
      1. org.springframework.validation.AbstractPropertyBindingResult.formatFieldValue(AbstractPropertyBindingResult.java:125)
      2. org.springframework.validation.AbstractBindingResult.getFieldValue(AbstractBindingResult.java:222)
      2 frames
    4. Spring MVC
      RequestContextAwareTag.doStartTag
      1. org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:120)
      2. org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:179)
      3. org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:199)
      4. org.springframework.web.servlet.tags.form.LabelTag.autogenerateFor(LabelTag.java:130)
      5. org.springframework.web.servlet.tags.form.LabelTag.resolveFor(LabelTag.java:120)
      6. org.springframework.web.servlet.tags.form.LabelTag.writeTagContent(LabelTag.java:90)
      7. org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:103)
      8. org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80)
      8 frames
    5. org.apache.jsp
      activate_jsp._jspService
      1. org.apache.jsp.WEB_002dINF.tiles.body.account.activate_jsp._jspx_meth_form_label_2(activate_jsp.java:667)
      2. org.apache.jsp.WEB_002dINF.tiles.body.account.activate_jsp._jspService(activate_jsp.java:224)
      2 frames