struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <mgai...@hotmail.com>
Subject RE: ognl method lookup failure
Date Sun, 13 Dec 2009 03:38:39 GMT

yeah..the problem starts here
http://www.docjar.com/html/api/sun/reflect/DelegatingMethodAccessorImpl.java.html
   30   /** Delegates its invocation to another MethodAccessorImpl and can
   31       change its delegate at run time. */
   32   
   33   class DelegatingMethodAccessorImpl extends MethodAccessorImpl {
   34       private MethodAccessorImpl delegate;
   35   
   36       DelegatingMethodAccessorImpl(MethodAccessorImpl delegate) {
   37           setDelegate(delegate);
   38       }
   39   
   40       public Object invoke(Object obj, Object[] args)
   41           throws IllegalArgumentException, InvocationTargetException
   42       {
   43           return delegate.invoke(obj, args);
   44       }
either the MethodAccessorImpl delegate is incorrect
or the method is 'inaccessible' or is incorrect

to verify method if you have the context try this testcase from com.opensymphony.xwork2.util.reflection.ReflectionContext.java

    public static boolean isDenyMethodExecution(Map<String, Object> context) {
        return getBooleanProperty(ReflectionContextState.DENY_METHOD_EXECUTION, context);
    }

a simpler testcase would be 
<% 
try
{commentInTag.getClass().getMethod("isUserSubscribedViaEmail",currentUserInTag.getClass());
}
catch(NoSuchMethodException nsme)
{
System.err.println("NoSuchMethodException produced message = "+nsme.getMessage());
}
catch(SecurityException sec_exp)
{
System.err.println("SecurityException produced message  "+sec_exp.getMessage());
}
 %>

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#getMethod%28java.lang.String,%20java.lang.Class
hth
Martin Gainty 
______________________________________________ 
standard caveats apply



> Date: Sat, 12 Dec 2009 16:51:30 -0800
> Subject: Re: ognl method lookup failure
> From: musachy@gmail.com
> To: user@struts.apache.org
> 
> I would suggest to put a breakpoint in XWorkMethodAccessor.callMethod
> and see why it is not finding it.
> 
> musachy
> 
> On Sat, Dec 12, 2009 at 1:44 PM, Dale Newfield <dale@newfield.org> wrote:
> > Often when I'm stumped writing a detailed "help!" message leads me to the
> > bug and I never have to send it.  This time I was not so lucky, and since
> > I've already wasted two days on this I was hoping someone here might have an
> > idea to get me out of the weeds.
> >
> > I've got an abstract class "Comment" and a bunch of concrete subclasses
> > thereof.  I've got a "displayComment.tag" file that calls itself recursively
> > to display a tree of comments.  Among other things this checks the extant
> > subscriptions on the comment in question and displays various
> > subscribe/unsubscribe buttons as appropriate.
> >
> > Mostly this works.  There are a couple concrete subclasses of Comment that
> > break in a bizarre way, and I've been stuck on this for two days, so I'm
> > hoping someone here might have a suggestion.
> >
> > I go through the normal annoying dance to push ognl accessible objects into
> > jstl-el accessible locations, passing those as attributes into the .tag file
> > and then set them inside the tag into a namespace accessible from ognl:
> >  (yes, I tried with #attr, too--same behavior)
> >
> > inside the .tag:
> > <%@ attribute name="currentUser" required="true" type="mumble.model.User"
> > rtexprvalue="true"%>
> > <%@ attribute name="commentToDisplay" required="true"
> > type="mumble.model.Comment" rtexprvalue="true"%>
> >
> > <c:set var="currentUserInTag" scope="request" value="${currentUser}"/>
> > <c:set var="commentInTag" scope="request" value="${commentToDisplay}"/>
> >
> > Simple tests:  <s:property value="%{#request.currentUserInTag.class}"/> and
> > <s:property value="%{#request.commentInTag.class}"/> show the appropriate
> > (concrete) classes.
> >
> > Whereas in most instances this OGNL logic works:
> > #request.commentInTag.isUserSubscribedViaEmail(#request.currentUserInTag)
> >
> > for these two specific concrete classes (due I believe to
> > struts.ognl.logMissingProperties=true) it results in a log entry:
> > Could not find method
> > [#request.commentInTag.isUserSubscribedViaEmail(#request.currentUserInTag)]
> >
> > I am able to interrogate the object and find the expected methods:
> > <s:property value="%{#request.commentInTag.class.methods.{?
> > #this.name=='isUserSubscribedViaEmail'}[0]}"/> results in "public boolean
> > mumble.model.CommunityFunItem.isUserSubscribedViaEmail(mumble.model.User)
> >
> > but I'm also unable to get further with that: <s:property
> > value="%{#request.commentInTag.class.methods.{?
> > #this.name=='isUserSubscribedViaEmail'}[0].invoke(#request.commentInTag,#request.currentUserInTag)}"/>
> > results in the log entry:  Could not find method
> > [#request.commentInTag.class.methods.{?
> > #this.name=='isUserSubscribedViaEmail'}[0].invoke(#request.commentInTag,#request.currentUserInTag)]
> >
> > Maybe related: if I try to access the Class method "Method getMethod(String
> > name, Class... parameterTypes)" directly to get the right one (instead of
> > getting all of them and looking for one with the right name) I end up with
> > this log message:
> >
> > Caught an exception while evaluating expression
> > '#request.commentInTag.class.getMethod('isUserSubscribedViaEmail',#request.currentUserInTag.class)'
> > against value stack
> > java.lang.IllegalArgumentException: java.lang.ClassCastException@ab1dea
> >        at sun.reflect.GeneratedMethodAccessor1387.invoke(Unknown Source)
> >        at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >        at java.lang.reflect.Method.invoke(Method.java:585)
> >        at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:851)
> >
> >
> > Again, this works with some concrete subclasses of Comment, but not others.
> >  There are no substantial differences between them as far as I can tell.
> >  Any ideas/leads/suggestions/suppositions welcome.
> >
> > I'm using struts 2.1.8.1, ognl 2.7.3, yes I have javassist-3.8.1.jar in
> > WEB-INF/lib.  Running under glassfish if that matters.
> >
> > -Dale
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
 		 	   		  
_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
http://clk.atdmt.com/GBL/go/171222986/direct/01/
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message