struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Miguel" <mig...@almeida.at>
Subject Re: help with MethodFailedException in ognl.OgnlRuntime.callAppropriateMethod
Date Tue, 03 May 2011 13:18:10 GMT
Which means: try changing your property name to something else; the tagId may already be in
use.

I also had a problem with a property name once. It might be useful to have a wiki page with
names already in use in struts.

Enviado a partir do meu HTC

----- Reply message -----
De: "Eric Reed" <EREED2@MAIL.NYSED.GOV>
Data: ter, Mai 3, 2011 13:37
Assunto: help with MethodFailedException in ognl.OgnlRuntime.callAppropriateMethod
Para: "Struts Users Mailing List" <user@struts.apache.org>

Justin,
 
Your error:
> [java.lang.NoSuchMethodException:
> org.robbins.flashcards.model.Tag.setTagId([Ljava.lang.String;)] <<----STRING
 
>    public void setTagId(int tagId) {  <-- INT
>        this.tagId = tagId;
>    }
Eric Reed
NYS Education Department
 

>>> Justin Robbins <justinhrobbins@gmail.com> 5/3/2011 8:32 AM >>>
Since the stack trace is at Warn level and doesn't actually seem to be
breaking my code then maybe I'm best off just adjusting the log4j
level higher for the Ognl related packages?

# Struts OgnlUtil issues unimportant warnings
log4j.logger.com.opensymphony.xwork2.util.OgnlUtil=error
log4j.logger.com.opensymphony.xwork2.ognl.OgnlValueStack=error

On Mon, May 2, 2011 at 9:27 PM, Justin Robbins <justinhrobbins@gmail.com> wrote:
> Nope, my bad.  After a full refactor I get the same error.  Below are
> snippets of the new code and most recently generated error.
>
> Stack Trace excerpt:
> 2011-05-02 21:24:49,887 175361 ["http-bio-8080"-exec-7] WARN
> com.opensymphony.xwork2.ognl.OgnlValueStack - Error setting expression
> 'tagId' with value '[Ljava.lang.String;@1e73e0d'
> ognl.MethodFailedException: Method "setTagId" failed for object
> org.robbins.flashcards.model.Tag@144dc7b [name='my tag' ]
> [java.lang.NoSuchMethodException:
> org.robbins.flashcards.model.Tag.setTagId([Ljava.lang.String;)]
>        at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1285)
>        at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1474)
>
> JSP excerpt:
> <s:form action="saveOrUpdateTag" method="post">
>        <s:hidden name="tagId" />
>        <s:textfield name="name" key="label.tag.name" size="20" />
>        <s:submit label="label.flashcard.submit" align="center" />
> </s:form>
>
> POJO excerpt:
> public class Tag  implements java.io.Serializable {
>
>
>     private int tagId;
>
>    public int getTagId() {
>        return this.tagId;
>    }
>
>    public void setTagId(int tagId) {
>        this.tagId = tagId;
>    }
>
> On Mon, May 2, 2011 at 8:53 PM, Justin Robbins <justinhrobbins@gmail.com> wrote:
>> I tested it just now and I do NOT get the error when I refactor the
>> code from the POJO on down to the JSP to use "myId" instead of "id".
>>
>> On Mon, May 2, 2011 at 8:43 PM, Dave Newton <davelnewton@gmail.com> wrote:
>>> Just out of curiosity, does it do the same thing if it's not named "id"?
>>>
>>> d.
>>>
>>> On Mon, May 2, 2011 at 8:32 PM, Justin Robbins <justinhrobbins@gmail.com>
wrote:
>>>> Anyone have any ideas on this one?  I'd be most grateful for some advice.
>>>>
>>>> Someone suggested I use a newer version of the ognl jar.  I was using
>>>> "ognl-3.0.jar" which is what came with the Struts 2.2.1.1
>>>> distribution.  I've since replaced it with "ognl-3.0.1.jar" but I'm
>>>> still receiving the same error.
>>>>
>>>> Any help is greatly appreciated.
>>>>
>>>> On Mon, May 2, 2011 at 11:26 AM, Justin Robbins
>>>> <justinhrobbins@gmail.com> wrote:
>>>>> Hi folks,
>>>>>
>>>>> I have a working Action and JSP form that I'm using for creating new
>>>>> entities in my very basic Struts 2.2.1.1 app.  I'm trying to modify
>>>>> the app to re-use the JSP form with editing of entities.  I added a
>>>>> hidden "ID" tag and now I'm getting errors when I submit the form.
>>>>> Can someone please give me some assistance?  I've Googled this issue
>>>>> and seen others posting similar errors but I'm not sure how to resolve
>>>>> it.
>>>>>
>>>>> Excerpt from Stack Trace when I submit the form:
>>>>> 2011-05-02 11:09:36,132 3198497 ["http-bio-8080"-exec-23] WARN
>>>>> com.opensymphony.xwork2.ognl.OgnlValueStack - Error setting expression
>>>>> 'id' with value '[Ljava.lang.String;@100ac03'
>>>>> ognl.MethodFailedException: Method "setId" failed for object
>>>>> org.robbins.flashcards.model.Tag@1b9eb34 [name='null' ]
>>>>> [java.lang.NoSuchMethodException:
>>>>> org.robbins.flashcards.model.Tag.setId([Ljava.lang.String;)]
>>>>>        at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1285)
>>>>>        at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1474)
>>>>>
>>>>> Excerpt from JSP:
>>>>> <%@ taglib prefix="s" uri="/struts-tags"%>
>>>>> ...
>>>>> <s:form action="saveOrUpdateTag" method="post">
>>>>>        <s:hidden name="id" />
>>>>>        <s:textfield name="name" key="label.tag.name" size="20" />
>>>>>        <s:submit label="label.flashcard.submit" align="center" />
>>>>> </s:form>
>>>>>
>>>>> Excerpt from Action Class:
>>>>> public class TagAction extends FlashCardsAppBaseAction implements
>>>>> ModelDriven<Tag> {
>>>>>
>>>>>        Tag tag = new Tag();
>>>>>
>>>>>        public Tag getTag() {
>>>>>                return tag;
>>>>>        }
>>>>>
>>>>>        public void setTag(Tag tag) {
>>>>>                this.tag = tag;
>>>>>        }
>>>>>        public String createTag() {
>>>>>        ...
>>>>>       }
>>>>> }
>>>>>
>>>>> Excerpt from POJO:
>>>>> public class Tag  implement
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message