I created an aspect with advices which performs some validation before and/or after returning from a method call. These advices may throw a validation exception if something is not ok. This exception is not in the original method signature.
If I try this with AspectJ, the code works as aspected and a validation exception is thrown and can be caught with a try/catch block.
When I try the same test in Spring 2.5.1 where I register <aop:aspectj-autoproxy/>, my aspect and the bean which the aspect should advise in the Spring config, the test receives a UndeclaredThrowableException which wraps my validation exception.
Any idea why in Spring I get an UndeclaredThrowableException? Compiled with AspectJ it works fine.
It should be possible with aspects to add a throw clause to an existing method, no? Or must such an exception always extend Error or RuntimeException?