If I have Annotation: and trying to use it as target marker of Spring AOP aspect joinpoint marker, it works well for some aspect, weaved by that composite pointcut: In other words, it works well as “straight-forward” annotation usage, when I write code like this: But in case of META-annotationR…
Tag: spring-aop
Spring is trying to subclass a record component when aop is present
I have a spring boot application in which I make use of aspects. Recently, I tried converting my @ConfigurationProperties classes to java records, but it fails with “Cannot subclass final class {..}Properties”. It seems spring is trying to make cglib proxies for my records, which obviously fail. I…
Spring AOP and AspectJ on same method
I have a question about using aspectJ and spring aop method intercepting. I created 2 annotations: @AJTest and @SAOPTest. registered it and other and register it and added it to my method in controller Application class but when i call it by http://localhost:8080/test?firstParam=test&secondParam=2 i can&#…
Not able to rollback DB changes in Aspect in Spring boot application
I have written one aspect around a service class. In the aspect, I am doing some operation in the before section, which I would like to be rolled back if some exception occurs in the enclosed service method. The service class is as follows: The aspect is as follows: I am seeing an exception in the service met…
Spring AOP @Pointcut and @Before yields IllegalArgumentException: error at ::0 formal unbound in pointcut
I am doing a springboot project that includes login and accounts. I am trying to @Pointcut all controller method calls and validate the login information, and @Before the pointcut to make sure the session exists. Hence the code: However, this yields org.springframework.beans.factory.BeanCreationException: Err…
Issues in serializing API request argument in Spring boot application
I have written one aspect to serialize the request arguments for APIs in Spring boot application, in DB as follows: The above code snippet is failing if we get HttpServletRequest/ByteStream as a request argument. For example, for byte stream I am getting following exceptions: For the request type of HttpServl…
Custom AOP spring boot annotation with ribbon client blocking api call with return “1”
I have really poor experience with ribbon/eureka so forgive me if this is a stupid question: I have two different microservice both connected to a discovery server, the first one calls the second …
Adding @Aspect throws BeanCreationException
I am trying to use AOP in Spring. When I am using old DTD methods in XML, things are working fine. But when I am trying to use AspectJ notations, I am facing some issues. I downloaded the JAR files for aspectj from here. I added them to the build path and the code containing @Aspect annotations compiled succe…
Is there a way of calling an advice method after execution of certain line of code using spring AOP
I have been wring Aspect for logging purpose. Now i am able to use before and after advice. But is it possible to call an advice after execution of certain line of business logic. Here is my current code and i want to substitute my code with advice. How to do that? My Aspect class How can i replace tightly
How to create pointcut to feign client that supports interface inheritance?
In a Spring Boot project I have a simple feign client I need to intercept all calls and for this and I’m creating a common library that can be used in different projects. To achieve it I try to use Spring AOP. I created an aspect that wraps all public methods of the object annotated with MyAnnotation It…