WebSphereUowTransactionManager causes exception for PROPAGATION_SUPPORTS when timeout is specified
See original GitHub issueContext
We’re upgrading a legacy app from Spring 1.2.8 (yes, for real) to Spring 4.3.6, following best practices and settings things right as we move along. We have everything working up to here except for this bug which required investigation and for which this is the report. Tested on WebSphere 8.5.5 and 9.0. We can’t move to Spring 5 yet because of a remaining dependence on Java 7, but I’d be expecting the same behavior from it after looking at the Spring code.
Details
The app is using XML configuration with per-method transaction management declared like so:
<tx:jta-transaction-manager />
[...]
<bean id="SomeApplicationBean" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref bean="transactionManager"/></property>
[...]
<property name="transactionAttributes">
<props>
<prop key="getQuestionsList">PROPAGATION_REQUIRED,timeout_60</prop>
Under Spring 4, this results at runtime in WebSphere throwing an exception:
java.lang.IllegalArgumentException: Invalid UOW type: 0
at com.ibm.ws.uow.UOWManagerImpl.setUOWTimeout(UOWManagerImpl.java:706)
at org.springframework.transaction.jta.WebSphereUowTransactionManager.execute(WebSphereUowTransactionManager.java:286)
Explanation
After investigation, it turns out that Spring’s JtaTransactionManager
tries to use the WebSphere Local Transaction manager (UOW_TYPE_LOCAL_TRANSACTION
) whenever possible. However, the WAS Local Transaction manager does not support timeouts.
Excerpt from IBM’s javadoc:
Throws: java.lang.IllegalArgumentException - Thrown if the specified type of UOW does not support timeout, e.g. UOW_TYPE_LOCAL_TRANSACTION.
Why it worked before
The Spring 1.2 transaction management was exclusively using the Global Transaction manager, which accepts the declared timeout with no issue.
Workaround
For now, we’ll be using our own custom copy of WebSphereUowTransactionManager
that’ll d avoid using UOW_TYPE_LOCAL_TRANSACTION
whenever a timeout is specified for the transaction. Obviously, a baked-in fix would be preferable, I am willing to supply a PR to that effect, although it would be initially against the 4.3 branch.
We’ll also be reviewing our declared timeouts for most operations but it is unlikely that we’ll get rid of them all.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
Let’s keep this issue open for my planned refinement in
WebSphereUowTransactionManager
timeout applicability, aligning it with the timeout handling in other transaction manager implementations. A reference back to your original upgrade hurdle here is very useful for that purpose. Thanks for the report, in any case!Good to hear that the upgrade was so straightforward in general…
Yes. I’ve understood what you meant about timeouts being useless in those cases. Adding the weight of your argument here should help me tip the balance in favor of removing them.
As a general note, upgrading from version to 1 to version 4 was incredibly straightforward - no big surprises. I’m a long time user and Spring still astounds me, both in technology and process. Looking forward to use version 5 and beyond, in both old and new projects.