Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AspectJ - Cannot register non aspect error

Tags:

java

aspectj

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?

like image 681
li-raz Avatar asked Apr 08 '26 01:04

li-raz


1 Answers

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

like image 175
Andy Clement Avatar answered Apr 21 '26 06:04

Andy Clement



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!