spring+ibatis分布式事务异常!!

问题描述

spring+ibatis分布式事务异常!!

spring + ibatis框架,使用jotm分布式事务控制,在运行过程中偶尔会出现异常,请高手指点。
spring配置文件:
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

<!--指定Spring配置中用到的属性文件 -->
<bean id="propertyConfig"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>WEB-INF/config/db/jdbc.properties</value>
            <value>WEB-INF/config/db/webservice.properties</value>
            <!-- <value>WEB-INF/config/db/cache.properties</value> -->
            <!-- 类路径的写法 <value>classpath:com/dhc/epos/demo/conf/jdbc-demo.properties</value> -->
        </list>
    </property>
    <property name="fileEncoding" value="UTF-8" />
</bean>

<!-- 分布式事务的配置方式 begin -->
<bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean">
     <property name="defaultTimeout" value="500000"/>
</bean>

<bean id="jtaTransactionManager"
    class="org.springframework.transaction.jta.JtaTransactionManager">
    <property name="userTransaction" ref="jotm" />
</bean>
<bean id="dataSource" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource"
    destroy-method="close">
    <property name="dataSource">
        <bean class="org.enhydra.jdbc.standard.StandardXADataSource"
            destroy-method="shutdown">
            <property name="transactionManager" ref="jotm" />
            <property name="driverName" value="${jdbc11.driverName}" />
            <property name="url" value="${jdbc11.url}" />
            <property name="user" value="${jdbc11.user}" />
            <property name="password" value="${jdbc11.password}" />
        </bean>
    </property>
    <property name="user" value="${jdbc11.user}" />
    <property name="password" value="${jdbc11.password}" />
</bean>
<bean id="dataSourceBi" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource"
    destroy-method="close">
    <property name="dataSource">
        <bean class="org.enhydra.jdbc.standard.StandardXADataSource"
            destroy-method="shutdown">
            <property name="transactionManager" ref="jotm" />
            <property name="driverName" value="${jdbc6.driverName}" />
            <property name="url" value="${jdbc6.url}" />
            <property name="user" value="${jdbc6.user}" />
            <property name="password" value="${jdbc6.password}" />
        </bean>
    </property>
    <property name="user" value="${jdbc6.user}" />
    <property name="password" value="${jdbc6.password}" />
</bean>
<bean id="dataSourceWms" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource"
    destroy-method="close">
    <property name="dataSource">
        <bean class="org.enhydra.jdbc.standard.StandardXADataSource"
            destroy-method="shutdown">
            <property name="transactionManager" ref="jotm" />
            <property name="driverName" value="${jdbc6.driverName}" />
            <property name="url" value="${jdbc6.url}" />
            <property name="user" value="${jdbc6.user}" />
            <property name="password" value="${jdbc6.password}" />
        </bean>
    </property>
    <property name="user" value="${jdbc6.user}" />
    <property name="password" value="${jdbc6.password}" />
</bean>

<bean id="dataSourceCrm" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource"
    destroy-method="close">
    <property name="dataSource">
        <bean class="org.enhydra.jdbc.standard.StandardXADataSource"
            destroy-method="shutdown">
            <property name="transactionManager" ref="jotm" />
            <property name="driverName" value="${jdbc6.driverName}" />
            <property name="url" value="${jdbc6.url}" />
            <property name="user" value="${jdbc6.user}" />
            <property name="password" value="${jdbc6.password}" />
        </bean>
    </property>
    <property name="user" value="${jdbc6.user}" />
    <property name="password" value="${jdbc6.password}" />
</bean>
<!-- 分布式事务的配置方式 end -->

<tx:advice id="txAdvice" transaction-manager="jtaTransactionManager">
    <tx:attributes>
        <tx:method name="get*" read-only="true" />
        <tx:method name="find*" read-only="true" />
        <tx:method name="exclusive__*"  propagation="REQUIRES_NEW" rollback-for="Exception"/>
        <tx:method name="*" propagation="REQUIRED" rollback-for="Exception" />
    </tx:attributes>
</tx:advice>

<aop:config>
    <aop:advisor pointcut="execution(* *..as*..*(..))" advice-ref="txAdvice"/>
</aop:config>

<!-- 与数据库类型无关的序号生成器 end -->
<import resource="classpath:com/dhc/sms/*/conf/applicationContext*.xml" />
<import resource="classpath:com/dhc/sms/ifm/*/conf/applicationContext*.xml" />

异常信息:
exception in ReceiveVipLevelDaoImpl.doInsertVipLevelList; nested exception is org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0];

--- The error occurred in /com/dhc/sms/webservice/crm/points/dao/ibatis/maps/ifm_vip_level_temp_et.xml.

--- The error occurred while executing mapped statement.

--- Check the IfmVipLevelTem.insert.

--- Check the statement or the result map.

--- Cause: java.sql.SQLException: StandardXAConnectionHandle:prepareStatement should not be used outside an EJBServer; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:

--- The error occurred in /com/dhc/sms/webservice/crm/points/dao/ibatis/maps/ifm_vip_level_temp_et.xml.

--- The error occurred while executing mapped statement.

--- Check the IfmVipLevelTem.insert.

--- Check the statement or the result map.

--- Cause: java.sql.SQLException: StandardXAConnectionHandle:prepareStatement should not be used outside an EJBServer

解决方案

看看这个。http://blog.csdn.net/fengxuezai/article/details/7673644

时间: 2024-08-02 04:46:10

spring+ibatis分布式事务异常!!的相关文章

Java中JDBC事务与JTA分布式事务总结与区别_java

Java事务的类型有三种:JDBC事务.JTA(Java Transaction API)事务.容器事务.常见的容器事务如Spring事务,容器事务主要是J2EE应用服务器提供的,容器事务大多是基于JTA完成,这是一个基于JNDI的,相当复杂的API实现.所以本文暂不讨论容器事务.本文主要介绍J2EE开发中两个比较基本的事务:JDBC事务和JTA事务. JDBC事务 JDBC的一切行为包括事务是基于一个Connection的,在JDBC中是通过Connection对象进行事务管理.在JDBC中,

分布式事务系列(1.2)Spring的事务体系

1 系列目录 分布式事务系列(开篇)提出疑问和研究过程 分布式事务系列(1.1)Spring事务管理器PlatformTransactionManager源码分析 分布式事务系列(1.2)Spring事务体系 分布式事务系列(2.1)分布式事务模型与接口定义 分布式事务系列(3.1)jotm的分布式案例 分布式事务系列(3.2)jotm分布式事务源码分析 分布式事务系列(4.1)Atomikos的分布式案例 2 三种事务模型 三种事务模型如下: 本地事务模型 编程式事务模型 声明式事务模型 先来

Spring多数据源分布式事务管理/springmvc+spring+atomikos[jta]+druid+mybatis

项目进行读写分离及分库分表,在一个业务中,在一个事务中处理时候将切换多个数据源,需要保证同一事务多个数据源数据的一致性.此处使用atomikos来实现:最后附源码: 1:spring3.0之后不再支持jtom[jta]了,第三方开源软件atomikos(http://www.atomikos.com/)来实现.  2:org.springframework.transaction.jta.JotmFactoryBean类,spring-tx-2.5.6.jar中有此类,spring-tx-3.0

System.Runtime.InteropServices.COMException (0x8004E00F): COM+ 无法与 Microsoft 分布式事务协调程序交谈 (异常来自 HRESU

错误信息: System.Runtime.InteropServices.COMException (0x8004E00F): COM+ 无法与 Microsoft 分布式事务协调程序交谈 (异常来自 HRESULT:0x8004E00F) 解决方案: 1.删除注册表中的键:     HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/MSDTC HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MSDTC HKEY

求助spring事务异常,报错报了昨天一天了55555,在线等啊

问题描述 求助spring事务异常,报错报了昨天一天了55555,在线等啊 就是一直都报这个错,昨天一天都没解决,感觉是确实一个方法,NoSuchMethodError:org.springframework.jdbc.datasource.DataSourceTransactionManager.determineTimeout,我导入源码看不到这个方法,只有一个调用它的参数,,,求大牛或者神牛帮帮忙,拜托了....困扰了一天啊,,,,!!!整个人都不好了,在线等!! 报错信息: Except

分布式事务系列(1.1)Spring事务管理器PlatformTransactionManager

1 系列目录 分布式事务系列(开篇)提出疑问和研究过程 分布式事务系列(1.1)Spring事务管理器PlatformTransactionManager源码分析 分布式事务系列(1.2)Spring事务体系 分布式事务系列(2.1)分布式事务模型与接口定义 分布式事务系列(3.1)jotm的分布式案例 分布式事务系列(3.2)jotm分布式事务源码分析 分布式事务系列(4.1)Atomikos的分布式案例 2 jdbc事务 2.1 例子 public void save(User user)

spring事务错误-spring+ibatis 事务错误

问题描述 spring+ibatis 事务错误 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentdao' defined in URL [file:/E:/资料/apache-tomcat-6.0.29/webapps/firstibatis/WEB-INF/classes/spring/applicationContext-jdbc.xml]: Erro

spring事务 异常-spring+hibernate注解开发异常,事务相关

问题描述 spring+hibernate注解开发异常,事务相关 异常信息: org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from tr

spring声明式事务解析_java

一.spring声明式事务 1.1 spring的事务管理器 spring没有直接管理事务,而是将管理事务的责任委托给JTA或相应的持久性机制所提供的某个特定平台的事务实现.spring容器负责事物的操作,spring容器充当切面,事务的方法称为增强处理,生成的代理对象的方法就是目标方法+增强也就是crud+事务程序员只用做crud的操作,也就是目标方法和声明哪些方法应该在事务中运行. Spring提供了许多内置事务管理器实现: DataSourceTransactionManager:位于or