For logging purposes, we're trying to catch various Spring's runtime exceptions via Spring's own AOP and I must say I've been unsuccessful, so I would appreciate any ideas as to how to approach this.
I've tried something like this:
@Aspect
@Component
public class SomeAspect {
@AfterThrowing(pointcut = "execution(* org.springframwork.oxm..*(..))", throwing = "exception")
@Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
public void adviseSpringErrorEvents(JoinPoint joinPoint, final UnmarshallingFailureException exception) throws Throwable {
LOG.debug(this.getClass().getSimpleName() + " - Error message advice fired on method: " + joinPoint.getSignature().getName());
}
}
The class is autoproxied and the rest of the advice in the aspect class correctly fire, so there has to be a problem with the AspectJ expression.
UPDATE: The code inside the method does not run and it is not my intention to catch the exception in the advice.
Any ideas? Thx in advance.
PS Spring framework version is 3.0.6.
Here are a couple of things that stand out to me:
execution(* com.mypackage..*(..))
.Things to try:
Exception
. Maybe the exception you are looking for is in a different hierarchy.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.