1

I'm trying to apply a cross cutting concern which is logging with AspectJ and a test framework called Katalon which uses Groovy and Java. I found that the best weaving type appropriate here is load-time weaving which requires a META-INF folder and an Aop.xml. I tried to put my aop.xml in multiple places but I think aspectj is unable to find it. This is the structure of my project:

enter image description here

Here is my aop.xml file content:

<aspectj>
    <aspects>
        <aspect name="com.fd.common.aspectName"/>
        <weaver options="-verbose -showWeaveInfo">
            <include within="com.myapp.common.*"/>
        </weaver>
    </aspects>
</aspectj>

And here is my aspect :

@Aspect
public class test {
    @org.aspectj.lang.annotation.Before("execution(* *.*(..))")
    public void bef (JoinPoint jp) {
        System.out.println(jp.getSignature());
        System.out.println("Beforeeeeeeeeeeeeeeeeeeeee");
    }
}
kriegaex
  • 63,017
  • 15
  • 111
  • 202
  • Welcome to SO. Please be more careful when writing questions next time, your inline image was not visible. I fixed that for you and also added syntax highlighting to your code snippets. – kriegaex Apr 13 '21 at 03:44

1 Answers1

0

My first guess, not having seen your real project, is that you should move the weaver options out of the aspect declaration section like this:

<aspectj>
    <aspects>
        <aspect name="com.fd.common.aspectName"/>
    </aspects>
    <weaver options="-verbose -showWeaveInfo">
        <include within="com.myapp.common.*"/>
    </weaver>
</aspectj>

If this does not help, I need more information. I have never used Katalon before, so I need to inspect your exact project setup - of course not your full original project, if proprietary. But please prepare an MCVE reproducing the problem, publish it on GitHub and I can take a look for you. I need to see how you call java and what is logged to the console.


Update: There was a follow-up question about how to use system property org.aspectj.weaver.loadtime.configuration in order to point to an alternative resource URL or file system path name. I answered the same question before here and have just updated it with some more detail.

kriegaex
  • 63,017
  • 15
  • 111
  • 202
  • Thank you for your reply. I have tried what you mentioned but it's not working as well. For the VM arguments are these one correct – samyyyy23423 Apr 13 '21 at 05:05
  • -Dorg.aspectj.weaver.loadtime.configuration=/Users/sam/Downloads/myProject_V2.7.6/META-INF/aop.xml -javaagent:/Users/sam/Downloads/aspectjweaver-1.9.6.jar – samyyyy23423 Apr 13 '21 at 05:08
  • Yes I wanted to mention in my comment that I'm going to do an MCVE but I want to ask my manger first then I pressed enter by mistake – samyyyy23423 Apr 13 '21 at 05:10
  • I will post my github code here if okay, thank you. – samyyyy23423 Apr 13 '21 at 05:12
  • FYI, I deleted my previous comments in favour of updating my answer, because SO is not a discussion forum and formatting is also easier in a question or answer. – kriegaex Apr 13 '21 at 05:41