Do you really need the first cast to Action? Anyway, could it be that you're having conflicting struts and/or application jars several places in your classloader hierarchy? That could explain certain "should never happen" incidents...
Nils-H On Fri, Jan 30, 2009 at 12:39 PM, Andy Sykes <a.sy...@ucl.ac.uk> wrote: > Hi Wes, > > No, I'm not using Spring at all. > > The Action never passes the test of being an instanceof Parseable. If I make > the action only implement SessionAware, and test if my action is an > instanceof SessionAware, the test is never passed! > > Colour me confused! > > Andy. > > > On 30 Jan 2009, at 00:55, Wes Wannemacher wrote: > >> On Thursday 29 January 2009 19:49:39 Andy Sykes wrote: >>> >>> Hi all, >>> >>> I've written an interceptor with a PreResultListener that gets the >>> action with ActionInvocation.getAction(), then casts it to an >>> interface ("Parseable", in this case). This lets me call a particular >>> method on the action just prior to the result being rendered. >>> >>> The action implements Parseable and SessionAware. >>> >>> When I do the cast, I get an ClassCastException for >>> com.opensymphony.xwork2.ActionSupport. If I take it down to one >>> interface (SessionAware) and cast the action to it, I still get a CCE. >>> What's weirder is I'm pretty sure this code worked on Struts 2.0.11. >>> >>> Here's a suitably simplified version of what I'm attempting to do: >>> >>> public String intercept(ActionInvocation invocation) throws Exception { >>> invocation.addPreResultListener(new PreResultListener() { >>> public void beforeResult(ActionInvocation invocation, >>> String resultCode) { >>> Action action = (Action)invocation.getAction(); >>> if (action instanceof Parseable) { >>> ((Parseable)action).parse(); >>> } >>> } >>> }); >>> >>> Any ideas what the hell is going on here? >>> >>> >> >> Is it possible that you are using Spring to instantiate your actions via >> the >> Spring plugin? It would seem that if the action passes the test, then the >> cast >> is legal. I ask about Spring in case the action is a proxied bean... It >> comes >> up from time to time that Spring created beans don't always seem to >> inherit >> every method that you would think... If Spring is in the mix, try having >> Spring use CGLIB... I've had some luck that way, vs. dynamic JDK proxies. >> >> -Wes >> >> -- >> >> Wes Wannemacher >> Author - Struts 2 In Practice >> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more >> http://www.manning.com/wannemacher >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org