Spring 配置分布式事务报错
Spring 配置JOTM分布式事务报错,如下:
org.hibernate.TransactionException: Could not find UserTransaction in JNDI [java:comp/UserTransaction]
at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:173)
at org.hibernate.transaction.JTATransactionFactory.createTransaction(JTATransactionFactory.java:149)
at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:195)
at org.hibernate.impl.SessionImpl.checkTransactionSynchStatus(SessionImpl.java:1889)
at org.hibernate.impl.SessionImpl.createCriteria(SessionImpl.java:1537)
at com.xzr.fie001.core02.dao.imp.CustomerDaoImpl.getCustomer(CustomerDaoImpl.java:38)
Spring配置如下:
<bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean" />
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="userTransaction"><ref local="jotm"/></property>
</bean>
<!-- 第一个数据源 -->
<bean id="innerMysqlDataSource" class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown">
<property name="transactionManager"><ref local="jotm"/></property>
<property name="driverName"><value>${jdbc.driverClassName}</value></property>
<property name="url"><value>${jdbc.url}</value></property>
</bean>
<bean id="dataSource" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown">
<property name="dataSource"><ref local="innerMysqlDataSource"/></property>
<property name="maxSize"><value>5</value></property>
<property name="minSize"><value>2</value></property>
<property name="user"><value>${jdbc.username}</value></property>
<property name="password"><value>${jdbc.password}</value></property>
</bean>
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan">
<list>
<value>com.xzr.fie001.core02.model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${hibernate.dialect}
</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
</props>
</property>
<property name="jtaTransactionManager">
<ref bean="jotm" />
</property>
</bean>
<!-- 第二个数据源 -->
<bean id="innerMysqlDataSource2" class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown">
<property name="transacti