Affects: \5.3.13
I'm extending JpaTransactionManager
(which extends AbstractPlatformTransactionManager
)
Creating a @Bean
of my class.
Then I get to this situation you see in the image which not suppose to be possible since the logger
is being initiated already.
protected transient Log logger = LogFactory.getLog(getClass());
It happens when I have an Aspect
for every method
@Pointcut("within(com.mydomain..*)")
public void everyMethodExecution() {
}
@Around("everyMethodExecution()")
public Object logAroundMethod(ProceedingJoinPoint joinPoint) throws Throwable {
Object o = joinPoint.proceed();
return o;
}
Comment From: mdeinum
This is due to the aspects. The aspects result in a proxy being generated. As the method is final
that cannot be proxied. What now happens is that the method is invoked on the proxy instead of passing through the proxy and eventually invoking the actual method. The proxy, due to its nature, doesn't have any of the fields initialized (or injected).
You might want to refine your pointcut expression to exclude this specific subclass of the JpaTransactionManager
, that way it won't be proxied and it will work as it should.
Comment From: sbrannen
You might want to refine your pointcut expression to exclude this specific subclass of the
JpaTransactionManager
, that way it won't be proxied and it will work as it should.
Indeed.
Before @mdeinum posted his comment, I was going to point out that your pointcut is too broad: it's rarely a good idea to have an aspect applied to every single bean in your project. Rather, you should apply aspects based on certain packages/types or based on the presence of specific annotations.
In light of the above, I am closing this issue as "works as designed".
Comment From: guy1699
Thanks for the explanation @mdeinum