NotReadablePropertyException: Invalid Property 'moduleName' Of Bean Class

- 1 answer

I am getting the following exception in Spring MVC application:

org.springframework.beans.NotReadablePropertyException: Invalid property 'moduleName' of bean class      [java.lang.String]: Bean property 'moduleName' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?

JSP Code

<form:form method="post" action="/submitSurvey" modelAttribute="surveyModule" > 
<form:label  path="moduleName">Module Name</form:label>
<form:input path="moduleName" />
<input type="submit" value="Save"/>

Spring Controller

@RequestMapping(value = "/submitSurvey", method = RequestMethod.POST)
public String submitSurvey(@ModelAttribute("surveyModule")SurveyModule sm, Model model){
    return "surveyHome";


public class SurveyModule {

private Integer surveyModuleId;
private String moduleName;

public Integer getSurveyModuleId() {
    return surveyModuleId;
public void setSurveyModuleId(Integer surveyModuleId) {
    this.surveyModuleId = surveyModuleId;
public String getModuleName() {
    return moduleName;
public void setModuleName(String moduleName) {
    this.moduleName = moduleName;

The property moduleName exist in the bean class. While I am able to use the property to get data, why I am getting this error? How can I correct this?



Do note that the error says

Invalid property 'moduleName' of bean class      [java.lang.String]

which means that ElResolver resolves surveyModule as String and not as a SurveyModule class. That means that there is an assignment with the same key, that is causing your problem. Check the keys you use for storing in other model attributes or session, also check that there is no <c:set var="surveyModule" somewhere in your page