Does anyone know how to invoke AspectJ annotations Ex: @Around with in Katalon

Does anyone know how to use AspectJ annotations Ex: @Around with in Katalon
I used with Spring framework before but I am unable to make it work with Katalon.
Below is the example.

import org.aspectj.lang.ProceedingJoinPoint
import org.aspectj.lang.annotation.Around
import org.aspectj.lang.annotation.Aspect
public class LoggerAspectJ {

	@Around("execution(* com.test..*.*(..))")
	public void logAround(ProceedingJoinPoint joinPoint) throws Throwable{
		KeywordUtil.logInfo("Around before is running")
		println "method name: "+joinPoint.getSignature().getName()
		KeywordUtil.logInfo("Around After is running")

I am not sure how to make it invoke within Katalon when I run my test cases or cucumber feature file. I would like to invoke before and after when my test case calls any keyword class.
any help is much appreciated.

Possibly you need to download some .jar files that implements @Aspect and @Around and make them accessible for your Groovy scripts.

See Libraries management | Katalon Docs

You can add any .jar files into the <projectDir>/Drivers folder of your Katalon project. Once you locate the required jar files into the Drivers folder, your Groovy script would compile.

Any more settings required for AspectJ? — I don’t know.

@kazurayam , Thanks for your reply, AspectJ jars are already available in Katalon by default. I am able to compile my code without any issue but I am unable to make it work within Katalon.

My question is how to configure within Katalon just like we do in Spring framework, so that my code can pick it up.

What is it? I don’t know what you mean. Any URL to refer to?

We define inside the spring configuration file as shown below to load aspectj-autoproxy:

Here is the link for more info:
Then at runtime, spring will execute those methods before, after or around our methods at run time.

A quote from

Spring AOP is obviously simpler because it doesn’t introduce any extra compiler or weaver between our build process. It uses runtime weaving, and therefore it integrates seamlessly with our usual build process. Although it looks simple, it only works with beans that are managed by Spring.

You can not have the Spring server up and running with Katalon Studio. You can not make your Katalon test code as beans managed by Spring — this doesn’t make sense at all. Therefore you would never be able to use Spring AOP in Katalon Studio.

However, to use AspectJ, we’re required to introduce the AspectJ compiler (ajc) and re-package all our libraries (unless we switch to post-compile or load-time weaving).
This is, of course, more complicated than the former – because it introduces AspectJ Java Tools (which include a compiler (ajc), a debugger (ajdb), a documentation generator (ajdoc), a program structure browser (ajbrowser)) which we need to integrate with either our IDE or the build tool.

You can not add the AspectJ compiler into Katalon Studio. Katalon Studio is equipped with Groovy(Java) compiler; that’s all and no more. Therefore you would never be able to use AspectJ in Katalon Studio.

So, I believe, you have no chance of utilizing Aspect Oriented Programming in Katalon Studio.

In my humble opinion, Katalon Studio is a tool for non-programmers. They would never know what AOP is, would never want it.

You would be able to develop a Selenium Java project with AspectJ, outside Katalon Studio.

Refer to

This helped me to write a Gradle build that makes AspectJ Aspects work with any Java classes. I think this will help you as well. Once you got it working, you would be able to extend the project to a Selenium Java project, which is essentially equivalent to a Katalon project, empowered by AspectJ. I believe that you, , are a real Java programmer, so that you wouldn’t need KS at all.

Hi @kazurayam , Thanks for taking time and finding the right information. I really appreciate that. Now, I understood, why it won’t work in katalon, by default aspectj works for .java files and the keywords of katalon are .groovy files. But I find aspectj as a nice addition though.

Not correct. Let me add some.

(1) you can write Java in KS

In Katalon project under the Include/scripts/groovy folder, you can create a file with post-fix .java = Java class source code.

The Groovy compiler will happily compile any .java source.

(2) you can not write AspectJ language in KS

The article How to make an AspectJ Aspect work in a Gradle project? explains you should name the file with post-fix .aj in which you write code in the AspectJ language. And you should locate the .aj file in the src/aspectj folder, not in the src/java folder. OK, you can do it even in Katalon Studio. The important point is that you need to introduce the AspectJ language compiler into your IDE(Eclipse, IDEA, …) or build tools (Gradle, Maven). You can NOT do this in Katalon Studio. Katalon Studio is not a general purpose IDE, it does not provide any means to add new language compilers. KS is speciallized to compile only .groovy of ver2.4 and .java of ver8.