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: , , , , , .

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Recent Posts

Recent Comments

Categories

Top Posts

Links

Blog Stats

Meta