Wednesday, June 22, 2011

org.springframework.beans.FatalBeanException: Could not copy properties from source to target

I came across this irritating issue(While workign on a Spring based project).

org.springframework.beans.FatalBeanException: Could not copy properties from source to target; nested exception is java.lang.IllegalArgumentException: argument type mismatch
at org.springframework.beans.BeanUtils.copyProperties(BeanUtils.java:599)
at org.springframework.beans.BeanUtils.copyProperties(BeanUtils.java:509)

Google took me to this bug which was already logged with SpringSource:

https://jira.springsource.org/browse/SPR-7693 (unfortunately it's still unfixed)

I made a quick fix/workaround for this.

Download/checkout : org.springframework.beans.BeanUtils.java

Add the below line after: writeMethod.invoke(target, value); (Around line 597) if using the 3.1 source.



if(logger.isDebugEnabled()){
logger.debug(MessageFormat.format("Source Property: {0}, Target Property:   {1}, Write method:{2}, Read Method {3} ", sourcePd.getName(),  targetPd.getName(), writeMethod.getName(), readMethod.getName()));
}

Add the file to your project. Now you can happily debug which property in the class is causing  problem.

2 comments:

Unknown said...
This comment has been removed by the author.
Unknown said...

Hi aneeshetta
Today, this article helped me
sathish