my dog learned polymorphism*
The moose likes Struts and the fly likes type converson failed in struts 2 : ognl.MethodFailedException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "type converson failed in struts 2 : ognl.MethodFailedException" Watch "type converson failed in struts 2 : ognl.MethodFailedException" New topic
Author

type converson failed in struts 2 : ognl.MethodFailedException

vikas byn
Ranch Hand

Joined: Mar 18, 2011
Posts: 80
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>
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

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


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

@Dear Moderator this problem has been resolved here http://www.coderanch.com/t/562175/Struts/type-converson-failed-struts-ognl please delete this thread.
vikas byn
Ranch Hand

Joined: Mar 18, 2011
Posts: 80
Mohan Rao Sv wrote:@Dear Moderator this problem has been resolved here http://www.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

Joined: Mar 18, 2011
Posts: 80
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: type converson failed in struts 2 : ognl.MethodFailedException
 
Similar Threads
Hibernate 3.3.1 - Delete doesn't work
newbie, execute method not working
Hibernate problem
Struts2 CannotRenderException
type converson failed in struts 2 : ognl.MethodFailedException