NotReadablePropertyException: Invalid property ‘key’ of bean class [java.lang.Integer] …
June 6, 2008
Problem:
It seems like, after the spring framework jars being used in the application were upgraded, all the form pages that made use of….
<form:select path="fooItem">
<form : options items="${fooItems}" itemValue="key" itemLabel="value"/>
</form:select>
… essentially the form:select and form : options stopped working. The following message was being displayed…
org.springframework.beans.NotReadablePropertyException: Invalid property 'key' of bean class [java.lang.Integer]: Bean property 'key' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
Solution:
The following part of the code was the problem-causer….
itemValue="key" itemLabel="value"
…. since when using the <form : options> tag where the items data is a Map, the itemValue and itemLabel attributes are unnecessary. Instead, spring simply uses the toString() of the map key for the option’s value, and the toString() of the map value as the option’s label. So the following modification got things up and running…
<form:select path="fooItem">
<form : options items="${fooItems}"/>
</form:select>
… that’s all.
Wa Allahu A’lam
Entry Filed under: Java, Spring. Tags: Bean property 'key' is not readable or has an invalid g, Does the return type of the getter match the parameter, Invalid property 'key' of bean class [java.lang.Integer, itemValue="key" itemLabel="value", NotReadablePropertyException + itemValue="key", org.springframework.beans.NotReadablePropertyException.
Trackback this post | Subscribe to the comments via RSS Feed