AspectJ aspect for @javax.transaction.Transactional is not initialised by default [SPR-16987] #21525
Comments
Juergen Hoeller commented Good point, we relied on an explicit bean definition for the |
Juergen Hoeller commented This is in master now, becoming available in the upcoming |
Mike B commented Thank you for the (very) quick response. Just one comment. Actually, in our project we happen to use both "javax.transaction.Transactional" and "org.springframework.transaction.annotation.Transactional". (I know it's not good but it's a large team so hard to enforce consistency.) Looking at your change, in the xml config, if "javax.transaction.Transactional" is present in the classpath, then both annotations are enabled. But in java config, only one is enabled. Could you do the same in java config, ie if "javax.transaction.Transactional" is present in the classpath, then enable support for both annotations. |
Juergen Hoeller commented This should work fine with Java config already since |
Mike B commented you are right, sorry, missed the inheritance. |
Mike B opened SPR-16987 and commented
If I
a) use Spring transaction management in the AspectJ mode
(
@EnableTransactionManagement
(mode = AdviceMode.ASPECTJ) )b) use the javax.transaction.Transactional annotation instead of org.springframework.transaction.annotation.Transactional
then
a) it doesn't work out of the box - transactions are not created around annotated methods.
b) I get "Skipping transactional joinpoint [] because no transaction manager has been configured" in the logs (if I enable spring debug logging).
This seems to be because the default configuration in AspectJTransactionManagementConfiguration only initialises AnnotationTransactionAspect but not JtaAnnotationTransactionAspect. So the JtaAnnotationTransactionAspect gets woven in by aspectJ compiler and executed but because it is not initialised with the transaction manager it cannot create transactions.
As a workaround, I can initialise it myself but declaring
@Bean
@Role
(BeanDefinition.ROLE_INFRASTRUCTURE)public JtaAnnotationTransactionAspect jtaTransactionAspect() {
return JtaAnnotationTransactionAspect.aspectOf();
}
But could you please add it to the default configuration so that it works out of the box.
Affects: 5.0.7
Issue Links:
Referenced from: commits 5b24040
The text was updated successfully, but these errors were encountered: