Spring MDP中的WebSphereUowTransactionManager问题

时间:2010-09-23 22:03:18

标签: spring websphere websphere-7

我在使用WebSphereUowTransactionManager在WebSphere 7.0中的Spring 3.0.4中设置MDP时遇到了问题。

如果我不使用WebSphereUowTransactionManager,它就可以了。没有它,我将不会对错误采取任何XA操作,所以我认为我真的需要它。

以下是服务器上发生的情况:

[9/22/10 16:26:35:093 CDT] 00000070 SystemOut     O 16:26:35.093 [WorkManager.DefaultWorkManager : 4] DEBUG o.s.t.j.WebSphereUowTransactionManager - Creating new transaction with name [jmsContainer]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
[9/22/10 16:26:36:140 CDT] 00000070 SystemOut     O 16:26:36.140 [WorkManager.DefaultWorkManager : 4] DEBUG o.s.j.l.DefaultMessageListenerContainer - Initiating transaction rollback on listener exception
java.lang.NullPointerException: null
    at org.springframework.jms.listener.AbstractMessageListenerContainer.commitIfNecessary(AbstractMessageListenerContainer.java:571) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:354) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:241) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1056) [org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:952) [org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.scheduling.commonj.DelegatingWork.run(DelegatingWork.java:61) [org.springframework.context.support-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext.java:1150) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.asynchbeans.WorkWithExecutionContextImpl.go(WorkWithExecutionContextImpl.java:199) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.asynchbeans.CJWorkItemImpl.run(CJWorkItemImpl.java:188) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550) [com.ibm.ws.runtime.jar:na]
[9/22/10 16:26:36:140 CDT] 00000070 SystemOut     O 16:26:36.140 [WorkManager.DefaultWorkManager : 4] DEBUG o.s.t.j.WebSphereUowTransactionManager - Initiating transaction rollback
[9/22/10 16:26:41:140 CDT] 00000070 SystemOut     O 16:26:41.140 [WorkManager.DefaultWorkManager : 4] WARN  o.s.j.l.DefaultMessageListenerContainer - Setup of JMS message listener invoker failed for destination 'queue://testQ?busName=WorkManagementBus' - trying to recover. Cause: null
java.lang.NullPointerException: null
    at org.springframework.jms.listener.AbstractMessageListenerContainer.commitIfNecessary(AbstractMessageListenerContainer.java:571) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:354) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:241) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1056) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:952) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.scheduling.commonj.DelegatingWork.run(DelegatingWork.java:61) [org.springframework.context.support-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext.java:1150) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.asynchbeans.WorkWithExecutionContextImpl.go(WorkWithExecutionContextImpl.java:199) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.asynchbeans.CJWorkItemImpl.run(CJWorkItemImpl.java:188) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550) [com.ibm.ws.runtime.jar:na]
[9/22/10 16:26:41:140 CDT] 00000070 SystemOut     O 16:26:41.140 [WorkManager.DefaultWorkManager : 4] INFO  o.s.j.l.DefaultMessageListenerContainer - Successfully refreshed JMS Connection

这是我的applicationContext.xml文件:

<bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager" />
<bean id="myTaskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
    <property name="workManagerName" value="wm/default" />
</bean>

<jee:jndi-lookup id="queue" jndi-name="jms/queue" resource-ref="true" proxy-interface="javax.jms.Queue"></jee:jndi-lookup>
<jee:jndi-lookup id="connectionFactory" jndi-name="jms/ConnectionFactory" resource-ref="true"></jee:jndi-lookup>

<bean id="jmsContainer"
    class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="connectionFactory" ref="connectionFactory"></property>
    <property name="destination" ref="queue"></property>
    <property name="messageListener" ref="testMessageListener"></property>

    <property name="taskExecutor" ref="myTaskExecutor"></property>
    <property name="transactionManager" ref="transactionManager"></property>
</bean>

<bean id="testMessageListener" class="navy.jmsey.TestMessageListener" />

我无法弄清楚为什么这不起作用。我想我正在做我应该做的一切。我按照http://www.ibm.com/developerworks/websphere/techjournal/0609_alcott/0609_alcott.html中的说明进行操作。

有人看过这个或看到我做错了吗?

感谢。

更新: 我已经尝试过做一个EJB3消息驱动的Bean,它按预期工作,例外情况下它被重新传递了5次。问题在于,依赖注入和事务包含的语义变得更加复杂。我很确定这不是我想去的方式。

更新: 我问过WebSphere支持,但他们拒绝了我。正如所料。

1 个答案:

答案 0 :(得分:1)

here似乎有一个JIRA。

该人说她设法通过替换

来使其工作
   commitIfNecessary(session, message); // line 354

   commitIfNecessary(sessionToUse, message); 

AbstractMessageListenerContainer.java班。