li-raz li-raz -3 years ago 54
Java Question

AspectJ - Cannot register non aspect error

I am trying to play with AspectJ and run time weaving.
I have created an aspect

@Aspect(value = "TraceAspect")
public class TraceAspect {
@Around("execution(* *(..))")
public Object around(ProceedingJoinPoint invocation) throws Throwable{

System.out.println(String.format("Invocing %s", invocation.getSignature().getName()));
try {
Object ret = invocation.proceed();
System.out.println(String.format("Done Invocing %s", invocation.getSignature().getName()));
return ret;
} catch (Throwable throwable) {
throw throwable;

}

}
}


and my aop.xml file is

<aspectj>
<aspects>
<aspect name="TraceAscpect"></aspect>
</aspects>
<weaver options="-debug -showWeaveInfo"/>




however when I run the program I get exception -

java.lang.RuntimeException: Cannot register non aspect: TraceAscpect , TraceAscpect


What did I forget to add?

Answer Source

Looks like you have spelt the name of your aspect wrong in your XML definition, it should be TraceAspect and you've put TraceAscpect.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download