zhaoxnshow 2015-07-01 09:44 采纳率: 0%
浏览 1982

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

  • 写回答

1条回答

  • lhl_lqc 2015-07-01 10:10
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 我想在一个软件里添加一个优惠弹窗,应该怎么写代码
  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流