org.springframework.context.support.DefaultMessageSourceResolvable: codes [foo.bar,bar]; arguments []; default message [bar]]; default message [Failed to convert property value of type 'org.sample.core.Bar' to required type 'org.sample.core.Bar' for property 'bar'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type org.sample.core.Bar to type @javax.persistence.ManyToOne org.sample.core.Bar for value 'org.sample.core.Bar@0'; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Provided id of the wrong type for class org.sample.core.Bar. Expected: class java.lang.Long, got class org.sample.core.Bar; nested exception is java.lang.IllegalArgumentException: Provided id of the wrong type for class org.sample.core.Bar. Expected: class java.lang.Long, got class org.sample.core.Bar]

Spring JIRA | Pablo Krause | 3 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

    *Input:* http://localhost/foo?name=MyFoo&bar.name=MyBar *Expected result:* {noformat} { "name" : "MyFoo", "bar" : { "name" : "MyBar" } } {noformat} *Actual result:* {noformat} Field error in object 'foo' on field 'bar': rejected value [org.sample.core.Bar@0]; codes [typeMismatch.foo.bar,typeMismatch.bar,typeMismatch.org.sample.core.Bar,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [foo.bar,bar]; arguments []; default message [bar]]; default message [Failed to convert property value of type 'org.sample.core.Bar' to required type 'org.sample.core.Bar' for property 'bar'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type org.sample.core.Bar to type @javax.persistence.ManyToOne org.sample.core.Bar for value 'org.sample.core.Bar@0'; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Provided id of the wrong type for class org.sample.core.Bar. Expected: class java.lang.Long, got class org.sample.core.Bar; nested exception is java.lang.IllegalArgumentException: Provided id of the wrong type for class org.sample.core.Bar. Expected: class java.lang.Long, got class org.sample.core.Bar] org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors Field error in object 'foo' on field 'bar': rejected value [org.sample.core.Bar@0]; codes [typeMismatch.foo.bar,typeMismatch.bar,typeMismatch.org.sample.core.Bar,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [foo.bar,bar]; arguments []; default message [bar]]; default message [Failed to convert property value of type 'org.sample.core.Bar' to required type 'org.sample.core.Bar' for property 'bar'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type org.sample.core.Bar to type @javax.persistence.ManyToOne org.sample.core.Bar for value 'org.sample.core.Bar@0'; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Provided id of the wrong type for class org.sample.core.Bar. Expected: class java.lang.Long, got class org.sample.core.Bar; nested exception is java.lang.IllegalArgumentException: Provided id of the wrong type for class org.sample.core.Bar. Expected: class java.lang.Long, got class org.sample.core.Bar] at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:112) ~[spring-web-4.0.3.RELEASE.jar:4.0.3.RELEASE] {noformat} *The players:* {code:title=Foo.java} @Entity public class Foo implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String name; @ManyToOne private Bar bar; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Bar getBar() { return bar; } public void setBar(Bar bar) { this.bar = bar; } public String getName() { return name; } public void setName(String name) { this.name = name;} } {code} {code:title=Bar.java} @Entity public class Bar *implements Serializable* { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String name; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } {code} {code:title=SampleController.java} @Controller @RequestMapping("/") public class SampleController { @ResponseBody @RequestMapping(value = "/foo", method = RequestMethod.GET) public Foo searchFoo(Foo foo) { return foo; } } {code} *The victim:* If you remove the "implements Serializable" from {{Bar}} you get the correct expected behavior. *Final comments:* In this particular case, I don't wan the DomainClassConverter to kick in, as explained in reference documentation section 1.4. I just want vanilla data binding, but for some reason the DomainClassConverter gets confused. For example, If I remove spring data's magic by removing the @EnableSpringDataWebSupport annotation in my setup, conversion works as expected.

    Spring JIRA | 3 years ago | Pablo Krause
    org.springframework.context.support.DefaultMessageSourceResolvable: codes [foo.bar,bar]; arguments []; default message [bar]]; default message [Failed to convert property value of type 'org.sample.core.Bar' to required type 'org.sample.core.Bar' for property 'bar'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type org.sample.core.Bar to type @javax.persistence.ManyToOne org.sample.core.Bar for value 'org.sample.core.Bar@0'; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Provided id of the wrong type for class org.sample.core.Bar. Expected: class java.lang.Long, got class org.sample.core.Bar; nested exception is java.lang.IllegalArgumentException: Provided id of the wrong type for class org.sample.core.Bar. Expected: class java.lang.Long, got class org.sample.core.Bar]
  2. 0

    *Input:* http://localhost/foo?name=MyFoo&bar.name=MyBar *Expected result:* {noformat} { "name" : "MyFoo", "bar" : { "name" : "MyBar" } } {noformat} *Actual result:* {noformat} Field error in object 'foo' on field 'bar': rejected value [org.sample.core.Bar@0]; codes [typeMismatch.foo.bar,typeMismatch.bar,typeMismatch.org.sample.core.Bar,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [foo.bar,bar]; arguments []; default message [bar]]; default message [Failed to convert property value of type 'org.sample.core.Bar' to required type 'org.sample.core.Bar' for property 'bar'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type org.sample.core.Bar to type @javax.persistence.ManyToOne org.sample.core.Bar for value 'org.sample.core.Bar@0'; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Provided id of the wrong type for class org.sample.core.Bar. Expected: class java.lang.Long, got class org.sample.core.Bar; nested exception is java.lang.IllegalArgumentException: Provided id of the wrong type for class org.sample.core.Bar. Expected: class java.lang.Long, got class org.sample.core.Bar] org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors Field error in object 'foo' on field 'bar': rejected value [org.sample.core.Bar@0]; codes [typeMismatch.foo.bar,typeMismatch.bar,typeMismatch.org.sample.core.Bar,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [foo.bar,bar]; arguments []; default message [bar]]; default message [Failed to convert property value of type 'org.sample.core.Bar' to required type 'org.sample.core.Bar' for property 'bar'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type org.sample.core.Bar to type @javax.persistence.ManyToOne org.sample.core.Bar for value 'org.sample.core.Bar@0'; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Provided id of the wrong type for class org.sample.core.Bar. Expected: class java.lang.Long, got class org.sample.core.Bar; nested exception is java.lang.IllegalArgumentException: Provided id of the wrong type for class org.sample.core.Bar. Expected: class java.lang.Long, got class org.sample.core.Bar] at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:112) ~[spring-web-4.0.3.RELEASE.jar:4.0.3.RELEASE] {noformat} *The players:* {code:title=Foo.java} @Entity public class Foo implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String name; @ManyToOne private Bar bar; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Bar getBar() { return bar; } public void setBar(Bar bar) { this.bar = bar; } public String getName() { return name; } public void setName(String name) { this.name = name;} } {code} {code:title=Bar.java} @Entity public class Bar *implements Serializable* { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String name; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } {code} {code:title=SampleController.java} @Controller @RequestMapping("/") public class SampleController { @ResponseBody @RequestMapping(value = "/foo", method = RequestMethod.GET) public Foo searchFoo(Foo foo) { return foo; } } {code} *The victim:* If you remove the "implements Serializable" from {{Bar}} you get the correct expected behavior. *Final comments:* In this particular case, I don't wan the DomainClassConverter to kick in, as explained in reference documentation section 1.4. I just want vanilla data binding, but for some reason the DomainClassConverter gets confused. For example, If I remove spring data's magic by removing the @EnableSpringDataWebSupport annotation in my setup, conversion works as expected.

    Spring JIRA | 3 years ago | Pablo Krause
    org.springframework.context.support.DefaultMessageSourceResolvable: codes [foo.bar,bar]; arguments []; default message [bar]]; default message [Failed to convert property value of type 'org.sample.core.Bar' to required type 'org.sample.core.Bar' for property 'bar'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type org.sample.core.Bar to type @javax.persistence.ManyToOne org.sample.core.Bar for value 'org.sample.core.Bar@0'; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Provided id of the wrong type for class org.sample.core.Bar. Expected: class java.lang.Long, got class org.sample.core.Bar; nested exception is java.lang.IllegalArgumentException: Provided id of the wrong type for class org.sample.core.Bar. Expected: class java.lang.Long, got class org.sample.core.Bar]
  3. 0

    AngularJS Drop Down Spring MVC JSON

    Stack Overflow | 2 years ago | Ahmed
    org.springframework.context.support.DefaultMessageSourceResolvable: codes [site.siteesTypeSite,siteesTypeSite]; arguments []; default message [siteesTypeSite]]; default message [Failed to convert property value of type 'java.lang.String' to required type '.model.TypeSites' for property 'siteesTypeSite'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [model.TypeSites] for property 'siteesTypeSite': no matching editors or conversion strategy found]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    submit dropdown angularjs spring MVC

    Stack Overflow | 2 years ago | Ahmed
    org.springframework.context.support.DefaultMessageSourceResolvable: codes [site.siteesTypeSite,siteesTypeSite]; arguments []; default message [siteesTypeSite]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'model.TypeSites' for property 'siteesTypeSite'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [model.TypeSites] for property 'siteesTypeSite': no matching editors or conversion strategy found]
  6. 0

    BigDecimal validation not working with encType=multipart

    Stack Overflow | 4 years ago | Sandhya
    org.springframework.context.support.DefaultMessageSourceResolvable: codes [layout.totalAreaInAcres,totalAreaInAcres]; arguments []; default message [totalAreaInAcres]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.math.BigDecimal' for property 'totalAreaInAcres'; nested exception is java.lang.NumberFormatException]

    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.context.support.DefaultMessageSourceResolvable

      codes [foo.bar,bar]; arguments []; default message [bar]]; default message [Failed to convert property value of type 'org.sample.core.Bar' to required type 'org.sample.core.Bar' for property 'bar'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type org.sample.core.Bar to type @javax.persistence.ManyToOne org.sample.core.Bar for value 'org.sample.core.Bar@0'; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Provided id of the wrong type for class org.sample.core.Bar. Expected: class java.lang.Long, got class org.sample.core.Bar; nested exception is java.lang.IllegalArgumentException: Provided id of the wrong type for class org.sample.core.Bar. Expected: class java.lang.Long, got class org.sample.core.Bar]

      at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument()
    2. Spring
      ModelAttributeMethodProcessor.resolveArgument
      1. org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:112)[spring-web-4.0.3.RELEASE.jar:4.0.3.RELEASE]
      1 frame