Take the 2-minute tour ×

I am trying to get XA transactions working in a Spring v3 application inside WebSphere v7.

My App Context reads:

<bean id="jmsConnectionFactory" 
    <property name="jndiName" value="jms/MQConnectionFactory"/>
    <property name="resourceRef" value="true"/>


<jee:jndi-lookup id="myDB" jndi-name="jdbc/myDB"/>

<bean id="txManager"
    class="org.springframework.transaction.jta.WebSphereUowTransactionManager" />


I'm referencing this article that says mix in the UOW txn manager and you'll be fine. But it doesn't work that way. Instead, in the following code, the message is destructively read and is not rolled back when an exception is thrown.

The transactional logic is (in scala):

@Transactional(rollbackFor = Array(classOf[Throwable]))
def processNextMessage(category: String) = {
  val maybeMessage = readNextMessage(category) // <- this is a destructive read

  for (message <- maybeMessage) {
    // this is temporary code for testing
    throw new RuntimeException("blaaaaaah")
    // end temporary code

    // sendToQueue(message, queue)
    // writeToMessageStore(message)

Can anyone advise how I can use WebSphere's JTA transaction manager with Spring?

share|improve this question
How is the connectionFactory used by the jmsTemplate configured? Is the transactionManager property of the jmsTemplate set? –  gkamal Mar 24 '11 at 7:44
There's no transactionManager property on jmsTemplate. And I read that the annotation approach means no explicit injection is required. –  Synesso Mar 24 '11 at 23:18
add comment

1 Answer

First of all, I would really like to see the code for readNextMessage as that may be the culprit.

Is the queue connection factory set up as an XA resource. You are trying to use JTA for transactions, so as far as I know you need to configure the message qcf accordingly.

You do not have to setup the JmsTemplate for transactions, as these are handled by the QueueConnectionFactory.

On a side note: if you are just dealing with mq, you can skip the UOW JTA provider and use transacted JMS sessions, which should work fine.

share|improve this answer
add comment

Your Answer


