question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebSphereUowTransactionManager causes exception for PROPAGATION_SUPPORTS when timeout is specified

See original GitHub issue

Context

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:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
jhoellercommented, May 26, 2020

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…

0reactions
fralalondecommented, May 26, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Global transaction timeout error when content packs of object ...
Symptom. The following exception is written in SystemOut.log: ContentPackIn E com.ibm.ws.fabric.support.g11n.logging.
Read more >
Chapter 6. Managing transactions - Spring in Action, Third ...
no-rollback-for specifies exceptions for which the transaction should continue and not be rolled back. timeout, Defines a timeout for a long-running transaction ...
Read more >
Transaction Management - Springer Link
generic DataAccessException hierarchy, Spring's abstraction for transaction ... specify transactional rules via configuration, preventing these details from ...
Read more >
Reference Documentation - Spring
Specifying attributes to store in a Session with @SessionAttributes; 16.11.8. ... When the Spring documentation makes mention of a 'factory bean', ...
Read more >
Transaction Management in Spring - Tech Tutorials
Timeout - How long this transaction runs before timing out and being rolled back ... WebSphereUowTransactionManager- WebSphere-specific ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found