Wednesday, March 25, 2009

What's up with 0.0 not being mapped in Struts 2.1.6?

Recently converted to Struts 2.1.6, and I found a small problem. There were double values displaying in my JSP textfields as 0.0. When those values were submitted to my action which had a setQuantity (double quantity), I was receiving OGNL Exceptions saying that the method setQuantity([Ljava.lang.String;)] did not exist. Something similar to this:

[java.lang.NoSuchMethodException: setQuantity([Ljava.lang.String;)]  
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:823)
at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:964)
at
ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:75)
at
ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:131)
at
com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:28)


Well of course it did not exist, it was a double I was submitting. I wanted nothing to do with Strings on this field.

It turns out that this is a known issue with the xwork-2.1.2.jar file. So I was able to find the xwork-2.1.3.jar file from here:
http://jira.opensymphony.com/browse/XW-676

Once I added this to my project, the problem was solved and things are working nicely again. Enjoy!

No comments:

Post a Comment