Remarkably, I'm still new to Spring AOP and am trying to figure out how to handle what I think is a pretty straightforward use case.
We can argue about the architectural appropriateness, but putting that aside for a moment, I just wanted to write an aspect that could intercept exceptions being thrown from any Struts actions and log them (there is other error handling / presentation logic, but that is orthogonal to the logging concern).
So here's the relevant Spring configuration:
The Java class represented by the "throwableLogger" bean has one method, log(), that takes a Throwable as an argument.
<aop:aspect id="logStrutsActionThrowables" ref="throwableLogger">
<aop:pointcut id="strutsActionExecution" expression="execution(* com.company.product.admin.action..*.*(..))"/>
<aop:after-throwing pointcut-ref="strutsActionExecution" throwing="pThrowable" method="log"/>
We also have a strutsSpring.xml config file that registers each Struts action as a Spring bean, which I can also attach in a reply.
So what am I doing wrong? Is it not appropriate to specify Throwable as the parameter? Does it need to be Exception, as that is what is part of the Struts action's signature? Or is that not relevant, as a Throwable is an Exception.
I tried to test this by temporarily modifying one of our Struts actions to throw an AritmeticException upon executing a division by 0.
I'm open to any and all suggestions.
Thanks in advance.