This happens not all the time, but frequently, and it's annoying. When I try to get a value from <s:form /> other than String (declared in Action), it gives me an exception like java.lang.NoSuchMethodException.
Nov 23, 2011 4:13:20 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn WARNING: Error setting expression 'passengers' with value '[Ljava.lang.String;@157b2d' ognl.MethodFailedException: Method "setPassengers" failed for object com.deveto.struts.actions.BookFlightAction@14928cc [java.lang.NoSuchMethodException: com.deveto.struts.actions.BookFlightAction.setPassengers([Ljava.lang.String;)]
The code from Action:
private Integer passengers;
public Integer getPassengers() {
return passengers;
}
public void setPassengers(Integer passengers) {
this.passengers = passengers;
}
The jsp:
<s:form action="book-flight" theme="simple">
<s:textfield name="passengers" value=""/>
</s:form>
And it is strange that it happens at random all the time, not at some specific point. Do you guys have some advices?
Update: I found this:
1) https://bugs.java.com/bugdatabase/view_bug?bug_id=6434149
2) http://dev.bostone.us/2009/02/23/javaxfacesfacesexception-javalangclassnotfoundexception-ljavalangstring/#awp::2009/02/23/javaxfacesfacesexception-javalangclassnotfoundexception-ljavalangstring/ (but it is for Eclipse only)
value=0because""should be aStringand you only havesetPassanders(Integer)and notsetPassanders(String). Also you probably have to set thetypesomewhereintfield instead of Integer.