Dear all,

I came upon some strange behaviour with the AbstractPlatformTransactionManager.

In a spring-aop-scenario where we only use cglib-proxies (proxy-target-class="true") I defined an aspect which would be wrapped around the TransactionManager of the system. In the integration testing phase, I came upon a lot of tests failing with a NullPointerException in method getTransaction at line boolean debugEnabled = this.logger.isDebugEnabled();.

The problem immediately went away, once I redefined the pointcut so that the PTA is no longer covered by it.

Is it intended, that it is not possible to define a cglib proxy around the PlatformTransactionManager? I would assume that a solution would be to make the logger static?

Comment From: jhoeller

The problem is that getTransaction is final, so it is always being invoked on the proxy instance which has empty fields, rather than delegated to the actual target instance which has its fields populated. You should see corresponding warnings in the log.

The final markers on APTM's entry points are by design, following the template method pattern. We could remove them to allow for CGLIB proxying but since we don't see common cases for proxying a PTM, we'd rather stick with the current design there.

Comment From: drachenpalme

Thanks for the clarification. I missed the final modifier (as proxying the PTM was not intentional but rather a too broad definition of the pointcut). That, of course explains the behaviour...