BeanWrapperImpl| no matching editors or conversion strategy found




Asked on August 18, 2013
java.lang.IllegalStateException: Cannot convert value of type [org.springframework.beans.BeanWrapperImpl] to required type [com.mypack.Employee] for property  manager : no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:485)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:516)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1119)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:904)
at com.concretepage.SpringDemo.main(SpringDemo.java:14)
Caused by: java.lang.IllegalStateException: Cannot convert value of type [org.springframework.beans.BeanWrapperImpl] to required type [com.mypack.Employee] for property  manager : no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:241)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:470)
... 4 more


I am using BeanWrapper and trying to test with two bean but got below error.

Code snippet is 

           BeanWrapper emp = new BeanWrapperImpl(new Employee());
  emp.setPropertyValue("name","somename");
  emp.setPropertyValue("age","24");
  
  BeanWrapper company = new BeanWrapperImpl(new Company());
  company.setPropertyValue("name", "any company");
  company.setPropertyValue("director", emp);



Replied on August 18, 2013
Rahul, check your line of code
company.setPropertyValue("director", emp);

it  should be like
company.setPropertyValue("director",  emp.getWrappedInstance());

I hope it will help you.




Write Answer











©2024 concretepage.com | Privacy Policy | Contact Us