无法在 WAS 7.0 上将 Websphere WebSphereUowTransactionManager 与 Spring 3.0 一起使用

Red*_*ils 3 java spring hibernate

我们正在尝试从 Spring 1.2.8 升级到 Spring 3.0 但是,当我们尝试为 Websphere 配置 txManager 时,我总是遇到类转换异常。我们根据IBM提供的示例进行了尝试,但不起作用。我正在使用 WAS 7.0、Spring.3.0.5 和 hibernate.3.6.jars...这是 Spring 配置:

        <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="ewpDataSource" />
        <property name="mappingResources">
            <list>
                <value>com/fme/example/model/Person.hbm.xml</value>
            </list>
        </property>

        <property name="hibernateProperties">
     <props>
         <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
         <prop key="hibernate.show_sql">true</prop>
         <prop key="hibernate.format_sql">false</prop>
         <prop key="hibernate.default_schema">ORIG</prop>
         <prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
         <prop key="hibernate.use_sql_comments">true</prop>
        <prop  key="hibernate.transaction.factory_class">
                   org.hibernate.transaction.JTATransactionFactory
                </prop>
              <prop key="hibernate.transaction.manager_lookup_class">
                 org.hibernate.transaction.WebSphereExtendedJTATransactionLookup
              </prop>
    </props>
    </property>
    </bean>

<!--  Our Data source --->
<bean id="ewpDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="jdbc/TOI_ORIG" />
</bean>

<!--- Get the Web sphere Specific TX manager -->
<bean id="transactionManager"
    class="org.springframework.transaction.jta.WebSphereUowTransactionManager"/>

</beans>  
Run Code Online (Sandbox Code Playgroud)

我阅读了这篇文章并完全按照指定进行了尝试。 http://www.ibm.com/developerworks/websphere/techjournal/0609_alcott/0609_alcott.html 还尝试了 http://robertmaldon.blogspot.com/2006/09/using-websphere-transaction-manager.html

但我们收到了这个异常。

Caused by: java.lang.IllegalStateException: Cannot convert value of type [org.springframework.transaction.jta.WebSphereUowTransactionManager] to required type [javax.transaction.TransactionManager] for property 'transactionManager': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:447)
Run Code Online (Sandbox Code Playgroud)

我看到为Websphere 提供的类org.springframework.transaction.jta.WebSphereUowTransactionManager 没有在层次结构中的任何位置实现javax.transaction.TransactionManager。

任何想法?

Red*_*ils 5

我成功了。除了上面的休眠设置之外,这就是我所做的。

    The object of type WebSphereUowTransactionManager is not an instance of 
    javax.transaction.TransactionManager
    but there is superclass method inside WebSphereUowTransactionManager
    called getTransactionManager() 
    this returns object of type javax.transaction.TransactionManager


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

<!-- 
    Now call get getTransactionManager on WebSphereUowTransactionManager
            object.
 -->    
<bean id="tranSactionManager"
    class="javax.transaction.TransactionManager" 
    factory-bean="wasUOWTxnManagerObj"
    factory-method="getTransactionManager">
</bean> 
Run Code Online (Sandbox Code Playgroud)

通过此更改,您现在可以使用 WebSphereUowTransactionManager。希望这可以帮助。