Why is the server complaining about aspectOf missing?

I am currently trying to introduce Spring bean in AspectJ, as shown below, as I server (WAS Liberty Profile) continues to complain about the aspectOf method. Can I find out how to solve this problem?

context.xml applications

<aop:aspectj-autoproxy/> <import resource="/context-file-A.xml"/> 

A.xml file context

 <bean id="loggingAspect" class="com.huahsin.LoggingAspect" factory-method="aspectOf"> 

JAVA code

 @Aspect public class LoggingAspect { ... } 
+6
source share
3 answers

This is a common mistake when connecting class classes. This means that your aspect class in this case, LoggingAspect not been converted to an aspect that can be applied.

The 2 methods to weave your class into an aspect use the AJDT Eclipse plugin or the Maven AspectJ compiler plugin .

There are 3 ways to interweave aspects:

  • Creation at compilation time : compile either the target source or the aspect classes through the dedicated aspectj compiler;
  • Compilation followed by compilation : introduction of instructions on aspects of already compiled classes (can be applied to JAR files)
  • Three load time : enter aspect instructions into byte code during class loading, i.e. load the tool class instead of "raw",

Before a class of a class can be applied to a class, it must first be "woven" into an aspect.

The woven class aspect will contain these static methods .

+7
source

AspectJ must weave both - your aspect class and the target class.

Weaving your class aspect

Target Class Weaving

  • Adds calls to these methods.
+4
source

The problem is that your AspectJ merge process is not working. Thus, you call the aspectOf method for the regular Java class, and not for the AspectJ class.

A simple way to check this:

  • Weaving with a tool like the Eclipse AJDT plugin
  • Create a simple JUnit test with Spring.
  • Finally, run it inside WAS.
+2
source

All Articles