Sunday, April 6, 2008

I love Spring!

I love Spring! The season as well as the framework. :)
For example, for one of my clients I had to install XPlanner as a project tracking and monitoring tool. (Yeah! I know there maybe a better XP tool available but XPlanner is simple and client likes it!) Anyway .. .

I downloaded xplanner 0.7b7 and tried to install under Vista Premium, running JRE 6 and Tomcat 6. This version of XPlanner is built on Spring 1.2 and I got this error

“org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.apache.commons.collections.map.LinkedMap] to required type [java.util.HashMap]”

Checking onto source file showed that “MetaRepositoryImpl” takes a “java.util.Hashmap” as its “repositories” property. However for some reason Spring was constructing a LinkedMap instance for “< Map >” declaration in bean configuration. Hmmm .. needed further investigation but I did not have time!
Now I had two options:
1) I could modify the source of “MetaRepositoryImpl”.
2) Think about spring way - Below is what I did.
Previous=>

< property name="repositories">
< map>
< entry>
....
< /entry>
......
< /map>
< /property>



Changed to=>

< property name="repositories">
< bean class="java.util.HashMap">
< constructor-arg>
< map>
< entry>
....
< /entry>
......
< /map>
< /constructor-arg>
< /bean>
< /property>


Done! Spring saves the day!

No comments: