• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

type converson failed in struts 2 : ognl.MethodFailedException

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in my Test.class ,field1 is Double type.

in html code, <input type="text" name="field1" value="0.0"/>

when i submit form, it will throw this exception if value of field1 is 0 or 0.0 -
WARNING: Error setting value
ognl.MethodFailedException: Method "setField1" failed for object net.xxx.action.Test@16b98c3 [java.lang.NoSuchMethodException: setField1([Ljava.lang.String;)]
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:823)

---

I tried many tricks but problem will not solve.
1)
create log4j.properties and put only two lines
log4j.logger.com.opensymphony.xwork2.util.OgnlUtil=error
log4j.logger.com.opensymphony.xwork2.ognl.OgnlValueStack=error

if there is need to configure log4j then let me know.

2) create struts.properties
and put a line -
struts.devMode=false

3)in struts.xml
<struts>
<constant name="struts.devMode" value="false" />
<package ...
...
</package>
</struts>
 
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
provide setters and getters to the field field1 otherwise Ognl can't set the value. And make sure that those methods should be public.
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Dear Moderator this problem has been resolved here https://coderanch.com/t/562175/Struts/type-converson-failed-struts-ognl please delete this thread.
 
vikas byn
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mohan Rao Sv wrote:@Dear Moderator this problem has been resolved here https://coderanch.com/t/562175/Struts/type-converson-failed-struts-ognl please delete this thread.



actually that post is misunderstood. so post again.
 
vikas byn
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mohan Rao Sv wrote:provide setters and getters to the field field1 otherwise Ognl can't set the value. And make sure that those methods should be public.


setField1 and getField1 methods already are public.
case 1: if field1 is type of Double, then it throw exception for 0 and 0.0 otherwise its working fine.
case 2: if field1 is type of Double, its working fine.
so my question is that - why does struts 2 controller not accepting Double value 0 or 0.0
reply
    Bookmark Topic Watch Topic
  • New Topic