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.classcastexcept...@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-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to