You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Vijayakrishna <vk...@gmail.com> on 2009/09/06 11:03:35 UTC

ognl.MethodFailedException [java.lang.NoSuchMethodException: setEventTime([Ljava.lang.String;)]

Hi all,

I've an action class AddEvent. In that I've a property

       java.sql.Timestamp eventTime;

For this I've given getters and setters

	public Timestamp getEventTime() {
		return eventTime;
	}

	public void setEventTime(Timestamp eventTime) {
		this.eventTime = eventTime;
	}


But when I try to send a POST request to the action class
"http://localhost:8080/AddEvent" with parameter name="eventTime" and
value="03.09.2009 02:45:21",
I'm getting the following exception.

ognl.MethodFailedException: Method "setEventTime" failed for object
com.adsol.action.AddEvent@b51c29 [java.lang.NoSuchMethodException:
setEventTime([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 org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
	at java.lang.Thread.run(Thread.java:619)
/-- Encapsulated exception ------------\
java.lang.NoSuchMethodException: setEventTime([Ljava.lang.String;)
	at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:810)
	at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:964)
	at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:75)
	at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:131)
.......
.......


For that I've added the following setter function.

	public void setEventTime(String eventTime) {
		SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
		Date date = null;
		try{
			date = sdf.parse(eventTime);
			this.eventTime = new Timestamp(date.getTime());
		}catch(Exception e){
			this.eventTime = null;
			e.printStackTrace();
		}
	}

But this doesn't work. I'm still getting the same
"ognl.MethodFailedException  [java.lang.NoSuchMethodException:
setEventTime([Ljava.lang.String;)]".

How to solve this issue?

Thanks in advance

-Vijay

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: ognl.MethodFailedException [java.lang.NoSuchMethodException: setEventTime([Ljava.lang.String;)]

Posted by Dave Newton <ne...@yahoo.com>.
Vijayakrishna wrote:
> But this doesn't work. I'm still getting the same
> "ognl.MethodFailedException  [java.lang.NoSuchMethodException:
> setEventTime([Ljava.lang.String;)]".

That's because [java.langString; is an array, not a String.
> 
> How to solve this issue?

I'm not sure that there's default conversion for Timestamps; never tried 
it. I'd look there first.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org