I have below action class where customerId is integer. If i pass customerId
as string from UI(I know it should not be allowed but there are
ways user can do it), i get  exception ognl.MethodFailedException: . Please
find  stack trace at last
 @Results({
    @Result(name = "displayCustomer", location = "customer.jsp")
})
 public class CustomerAction{
  private int     customerId = -1;
 @Action("getCustomer!getCustomer")
  public String getCustomer() {
  ....
  return "displayCustomer";
  }

   public int getCustomerId() {
    return customerId;
  }

  public void setCustomerId(int customerId) {
    this.customerId = customerId;
  }


}
 Stack Trace
 2014-06-12 09:58:33,725 [http-8080-6] WARN  ognl.OgnlValueStack - Error
setting expression 'customerId' with value '[Ljava.lang.String;@35997e91'
ognl.MethodFailedException: Method "setCustomerId" failed for object
com.test.struts2fw.actions.CustomerAction@48819db7
[java.lang.NoSuchMethodException:
com.test.struts2fw.actions.CustomerAction.setCustomerId([Ljava.lang.String;)]
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1305)
at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1494)
at
ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)
at
com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:27)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2332)
at
com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:78)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2332)
at ognl.ASTProperty.setValueBody(ASTProperty.java:127)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
at ognl.Ognl.setValue(Ognl.java:737)
at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:218)
at
com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue(OgnlValueStack.java:187)
at
com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:174)
at
com.opensymphony.xwork2.ognl.OgnlValueStack.setParameter(OgnlValueStack.java:152)
at
com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:318)
Once this exception is encountered, it take flow to customer.jsp. What i
want is flow go to my Exception.jsp instead of result in case
of some ognl/struts 2 exception?

Reply via email to