- Spring 5.3.3
- Spring Boot 2.4.2
- AspectJ 1.9.6
We use AspectJ compile Time Weaving to manage @Transactional annotations. Everything works fine until we activate spring.main.lazy-initialization=true. The Transaction is not started.
The error is somewhere in TransactionAspectSupport, as the beanFactory is still null when running with lazy-init activated:
protected TransactionManager determineTransactionManager(@Nullable TransactionAttribute txAttr) {
// Do not attempt to lookup tx manager if no tx attributes are set
if (txAttr == null || this.beanFactory == null) {
return getTransactionManager();
}
I hope this is a spring issue and not a Spring Boot issue. I searched the docs if lazy-init is not supported with AspectJ but I did not found anything and didn't any other issue regarding this bug.
Very small project reproducing the issue: https://github.com/kicktipp/spring-lazy-aspectj-issue
Just checkout and run
./gradlew test --tests NonLazyTest
./gradlew test --tests LazyTest
First on with success, second one fails.
If you need further information I am eager to help.