-
Notifications
You must be signed in to change notification settings - Fork 38.5k
JtaTransactionManager created with the JtaTransactionManagerFactoryBean is not ready to use #22605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
TransactionManagerFactoryBeanDemo.zip A small demo-application attached to illustrate the problem. Attempting to use the transaction-manager fails with "org.springframework.transaction.CannotCreateTransactionException: No JTA UserTransaction available - programmatic PlatformTransactionManager.getTransaction usage not supported", because the JtaTransactionManager isn't initialized. Enabling the workaround in demo.spring.Config solves the problem (but that is no regular solution). |
@bbodnar, are you actively deploying your application to WebLogic or WebSphere? If not, there's no need to use the |
Yes, the software this is part of is used actively - besides JBoss/Wildfly - on Websphere Classic. |
@bbodnar, thanks for the feedback. I suppose we could introduce something like a Let's see what the rest of the team thinks. |
Would that new high-level type have any other feature than initializing the transaction manager? I'd introduce such a type only if we use the opportunity to add additional features. |
No, I don't think it would introduce any new features, and consequently it would not really be a "builder" but rather simply a "factory" (e.g.,
Understood.
So what about @bbodnar's above proposal?
@jhoeller, since you're listed as the sole author of |
A note to my proposal: in Spring's sources there are already few cases, where afterPropertiesSet() on beans implementing InitializingBean is called manually (i.e. not by the bean-factory):
I think, this would be also here the most straightforward solution. |
Indeed, letting |
@jhoeller: thank you for the fix! |
A JtaTransactionManager created with the JtaTransactionManagerFactoryBean (the only way to get the proper JTA-support when using a Java-configuration, introduced in [SPR-12197]) is not ready to use, because JtaTransactionManager is an InitializingBean and InitializingBean.afterPropertiesSet() is basically not called by Spring on factory-made beans.
Workarounds exist (eg. calling FactoryBean.getObject() on JtaTransactionManagerFactoryBean directly and exposing the result (the JtaTransactionManager) to the application-context/bean-factory), but that was surely not intended so by the authors. A possible solution would be to make JtaTransactionManagerFactoryBean an InitializingBean and perform the initialization of the actual transaction-manager, when Spring calls afterPropertiesSet() on the factory.
The text was updated successfully, but these errors were encountered: