Dec 22, 2010

How To Resolve 'org.springframework.core.convert.ConversionFailedException: Unable to convert value from type 'java.util.LinkedHashMap' to type 'java.util.Map'; nested exception is java.lang.IllegalArgumentException: Left-hand side type must not be null'

I had been using Spring framework 3.0.0. I had the requirement of passing an attribute map to one of my bean in the application context and I was using the conversion service as shown in the code snippet below
<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean" />

When ever I try to set the attribute map to the bean, it was giving me the following exception
org.springframework.core.convert.ConversionFailedException: Unable to convert value {<your value>} from type 'java.util.LinkedHashMap' to type 'java.util.Map'; nested exception is java.lang.IllegalArgumentException: Left-hand side type must not be null

The error was, of course. not helpful and did not give me any clue as to why and from where the problem emerged from. I was thinking that the objects, the key value, that I was passing was not of the expected type. However, since that was not the case, I had to explore a bit across the Internet in this regard. When I explored, I found that there is a problem with the conversionService bean in the Spring Framework version 3.0.0 that has been fixed in Spring Framework 3.0.1. This has been documented as a JIRA issue. A

As pointed out in the JIRA link, I observed that the problem was with the conversion service of the Spring version 3.0.0. Fortunately, the issue has been fixed in the 3.0.1 version itself.fter going through this, I ended up in downloading the latest Spring framework jars and the code started working like charm!

So, whenever you try to add an attribute map to any of your bean in the application context within a Spring 3.0.0 based application, and, if you are using a conversionService that references org.springframework.format.support.FormattingConversionServiceFactoryBean, and if you confront a problem like 'Unable to convert value from type 'java.util.LinkedHashMap' to type 'java.util.Map'; nested exception is java.lang.IllegalArgumentException: Left-hand side type must not be null', then please have a look at the JIRA issue and upgrade your jars accordingly.

Since I thought that this might help a few of you who are confronting similar issues, I have documented this and posted here. I appreciate your hollers/feedback regarding this post any time!

No comments:

Post a Comment