I am quite interested in your small Maven project. AFAIK, local variables should have no roles to play (good or bad!).
-Ramnivas
I am quite interested in your small Maven project. AFAIK, local variables should have no roles to play (good or bad!).
-Ramnivas
Ramnivas Laddad (Follow me on Twitter)
AspectJ in Action: Enterprise AOP with Spring Applications (2nd edition). Now available!
Attached is a simple maven project that reproduces the error. 2 classes, the aspect, and a test class to load the app context. Maybe I am just missing something obvious, but the behavior sure seems weird. If anybody has any thoughts, let me know![]()
I am also seeing this behavior. It occurs with both after-returning and after-throwing advice. If I build with Eclipse, everything works as it should. If I build with javac ( debug enabled ) I see the exception. I've tried switching to Load Time Weaving, forcing CGLIB proxies, etc. but nothing seems to work. I'm reluctant to move all of our automated builds to the Eclipse JDT compiler. Has there been any progress on this issue? Does anyone have another workaround?
My environment:
Using xml aop:config ( no mixing with annotations )
Spring 2.0, ASM 2.2.2, cglib-nodep-2.1.3
MyEclipse 5.1GA
Eclipse 1.5.2v20061111
jdk 1.5.0_07
Thanks,
Mark
I have created a JIRA issue to track this... We'll see what reply I get.
SPR-3307
So here's what I discovered. If I remove the "debug" flag from javac everything works at runtime ( no exception ).
However, we use cobertura for test coverage analysis which requires that the class files to be instrumented be compiled with debug enabled.
So instead of runtime weaving I tried compile time weaving ( i.e. using the AspectJ compiler ajc ). This is easy to setup and it solves the problem. I'm able to compile with debug enabled and I do not get the exception.
Here's a link to a post which specifies how to setup ajc in ant.
http://forum.springframework.org/sho...op.xml+weaving
Hope this helps,
Mark
I started getting the above exception after altering the following class in my app:
The commented out code above is what caused this exception.Code:@Aspect @Order(1) public class LoggingExceptionAdvice { private static Logger logger = Logger.getLogger(LoggingExceptionAdvice.class); @AfterThrowing(pointcut="za.co.metcapri.common.aop.SystemPointCuts.inCapri()",throwing="ex") public void afterThrowing(Exception ex) throws Throwable { if (!(ex instanceof BusinessException)){ // StringWriter stringWriter = new StringWriter(); // PrintWriter printWriter = new PrintWriter(stringWriter, true); // ex.printStackTrace(printWriter); // printWriter.close(); // logger.error(stringWriter.toString()); logger.error(ex); } } }
When I reverted back to just logging the exception, all was well again.
The problem is that logger.error(ex) only logs the first line and not the full stack trace.
Any ideas why the above code causes Advice configuration failure?
I tried the Spring example http://static.springsource.org/sprin.../html/aop.html
and here is my code
public class AfterThrowingExample {
public void doRecoveryActions() {
System.out.println(" AfterThrowingExample ");
}
}
applicationContext.xml
<bean id="afterThrowing" class="cs.comp.aop.AfterThrowingExample"/>
<aop:config>
<aop:aspect id="executionOfMethods" ref="afterThrowing">
<aopointcut id="afterThrowingPointCut"
expression="execution(* cs.comp.service.GeekTransactionService.addRecords* (..))" />
<aop:after-throwing
pointcut-ref="geekServicePointCut"
method="doRecoveryActions"/>
</aop:aspect>
</aop:config>
And it works fine for me