我的配置如下:
<!--jftcard datasoure-->
<bean id="jftcardDataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close">
<description>oracle jftcard datasource</description>
<property name="uniqueResourceName" value="oracle_jftcard" />
<property name="xaDataSourceClassName"
value="oracle.jdbc.xa.client.OracleXADataSource" />
<property name="xaProperties">
<props>
<prop key="user">jftcard</prop>
<prop key="password">jftcard</prop>
<prop key="URL">jdbc:oracle:thin:@192.168.1.38:1521:ORCL</prop>
</props>
</property>
<property name="maxPoolSize">
<value>10</value>
</property>
<property name="minPoolSize">
<value>2</value>
</property>
<property name="loginTimeout">
<value>30</value>
</property>
<property name="reapTimeout">
<value>20000</value>
</property>
<property name="poolSize" value="10" />
</bean>
<!--ic datasoure-->
<bean id="icDataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close">
<description>oracle ic datasource</description>
<property name="uniqueResourceName" value="oracle_ic"/>
<property name="xaDataSourceClassName" value="oracle.jdbc.xa.client.OracleXADataSource"/>
<property name="xaProperties">
<props>
<prop key="user">cnnctic</prop>
<prop key="password">test</prop>
<prop key="URL">jdbc:oracle:thin:@192.168.1.110:1521:ORCL</prop>
</props>
</property>
<!-- 连接池里面连接的个数? -->
<property name="poolSize" value="10"/>
</bean>
<!-- 配置SqlSessionFactoryBean -->
<bean id="sqlSessionFactoryIc" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="icDataSource" />
<property name="mapperLocations" >
<list>
<value>classpath*:com/cnnct/system/dao/*.xml"</value>
</list>
</property>
</bean>
<!-- 配置SqlSessionFactoryBean -->
<bean id="sqlSessionFactoryJftcard" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="jftcardDataSource" />
<property name="mapperLocations" >
<list>
<value>classpath*:com/cnnct/product/jftcardcs/dao/*.xml"</value>
</list>
</property>
</bean>
<!-- scan for mappers and let them be autowired -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.cnnct.Base,com.cnnct.system.dao,com.cnnct.auto.dao" />
<property name="sqlSessionFactory" ref="sqlSessionFactoryIc"/>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.cnnct.product.jftcardcs.Base,com.cnnct.product.jftcardcs.dao" />
<property name="sqlSessionFactory" ref="sqlSessionFactoryJftcard"/>
</bean>
<!-- 配置atomikos的事务管理器 -->
<!-- Construct Atomikos UserTransactionManager, needed to configure Spring -->
<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init" destroy-method="close">
<!-- when close is called, should we force transactions to terminate or not? -->
<property name="forceShutdown">
<value>true</value>
</property>
</bean>
<bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
<property name="transactionTimeout" value="20000" />
</bean>
<!-- spring的JTA事务管理器 -->
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager">
<ref bean="atomikosTransactionManager" />
</property>
<property name="userTransaction">
<ref bean="atomikosUserTransaction" />
</property>
<!-- 必须设置,否则程序出现异常 JtaTransactionManager does not support custom isolation levels by default -->
<property name="allowCustomIsolationLevels" value="true"/>
</bean>
<!--启动spring注解功能-->
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>
异常信息:
[16/09/13 02:59:01:001 CST] INFO pool.ConnectionPool: atomikos connection pool 'oracle_jftcard': destroying pool...
[16/09/13 02:59:01:001 CST] INFO jdbc.AbstractDataSourceBean: AtomikosDataSoureBean 'oracle_ic': close...
[16/09/13 02:59:01:001 CST] INFO pool.ConnectionPool: atomikos connection pool 'oracle_ic': destroying pool...
2013-09-16 14:59:01.993:WARN:oejw.WebAppContext:Failed startup of context o.e.j.w.WebAppContext{/cnnctInterfaceCenter,[file:/E:/tfs/cnnctInterfaceCenter/WebContent/]}
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'atomikosTransactionManager' defined in URL [file:/E:/tfs/cnnctInterfaceCenter/WebContent/WEB-INF/classes/conf/spring/spring-datasource-mutil.xml]: Invocation of init method failed; nested exception is com.atomikos.icatch.SysException: Error in init of UserTransactionServiceImp: com.atomikos.icatch.standalone.UserTransactionServiceFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:764)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:406)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:756)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:242)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1221)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:699)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
at org.eclipse.jetty.server.Server.doStart(Server.java:263)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at runjettyrun.Bootstrap.main(Bootstrap.java:80)
Caused by:
com.atomikos.icatch.SysException: Error in init of UserTransactionServiceImp: com.atomikos.icatch.standalone.UserTransactionServiceFactory
at com.atomikos.icatch.config.UserTransactionServiceImp.checkInit(UserTransactionServiceImp.java:350)
at com.atomikos.icatch.config.UserTransactionServiceImp.createTSInitInfo(UserTransactionServiceImp.java:362)
at com.atomikos.icatch.config.UserTransactionServiceImp.init(UserTransactionServiceImp.java:568)
at com.atomikos.icatch.jta.UserTransactionManager.startupTransactionService(UserTransactionManager.java:89)
at com.atomikos.icatch.jta.UserTransactionManager.checkSetup(UserTransactionManager.java:77)
at com.atomikos.icatch.jta.UserTransactionManager.init(UserTransactionManager.java:142)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1612)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:764)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:406)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:756)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:242)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1221)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:699)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
at org.eclipse.jetty.server.Server.doStart(Server.java:263)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at runjettyrun.Bootstrap.main(Bootstrap.java:80)
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:415)
at runjettyrun.ProjectClassLoader.loadClass(ProjectClassLoader.java:92)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.atomikos.util.ClassLoadingHelper.loadClass(ClassLoadingHelper.java:128)
at com.atomikos.icatch.config.UserTransactionServiceImp.checkInit(UserTransactionServiceImp.java:340)
at com.atomikos.icatch.config.UserTransactionServiceImp.createTSInitInfo(UserTransactionServiceImp.java:362)
at com.atomikos.icatch.config.UserTransactionServiceImp.init(UserTransactionServiceImp.java:568)
at com.atomikos.icatch.jta.UserTransactionManager.startupTransactionService(UserTransactionManager.java:89)
at com.atomikos.icatch.jta.UserTransactionManager.checkSetup(UserTransactionManager.java:77[16/09/13 02:59:01:001 CST] ERROR context.ContextLoader: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'atomikosTransactionManager' defined in URL [file:/E:/tfs/cnnctInterfaceCenter/WebContent/WEB-INF/classes/conf/spring/spring-datasource-mutil.xml]: Invocation of init method failed; nested exception is com.atomikos.icatch.SysException: Error in init of UserTransactionServiceImp: com.atomikos.icatch.standalone.UserTransactionServiceFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:764)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:406)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:756)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:242)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1221)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:699)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
at org.eclipse.jetty.server.Server.doStart(Server.java:263)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at runjettyrun.Bootstrap.main(Bootstrap.java:80)
Caused by: com.atomikos.icatch.SysException: Error in init of UserTransactionServiceImp: com.atomikos.icatch.standalone.UserTransactionServiceFactory
at com.atomikos.icatch.config.UserTransactionServiceImp.checkInit(UserTransactionServiceImp.java:350)
at com.atomikos.icatch.config.UserTransactionServiceImp.createTSInitInfo(UserTransactionServiceImp.java:362)
at com.atomikos.icatch.config.UserTransactionServiceImp.init(UserTransactionServiceImp.java:568)
at com.atomikos.icatch.jta.UserTransactionManager.startupTransactionService(UserTransactionManager.java:89)
at com.atomikos.icatch.jta.UserTransactionManager.checkSetup(UserTransactionManager.java:77)
at com.atomikos.icatch.jta.UserTransactionManager.init(UserTransactionManager.java:142)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1612)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
... 24 more
)
at com.atomikos.icatch.jta.UserTransactionManager.init(UserTransactionManager.java:142)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1612)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:764)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:406)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:756)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:242)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1221)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:699)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
at org.eclipse.jetty.server.Server.doStart(Server.java:263)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at runjettyrun.Bootstrap.main(Bootstrap.java:80)
2013-09-16 14:59:02.021:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8090
请大侠帮助指正一下
我使用包是
spring3.2
mybatis3
atomikos相关的包如下:
atomikos-util-3.9.0.M1.jar
mybatis-spring-1.2.0.jar
ow2-jta-1.1-spec-1.0.13.jar
transactions-3.9.0.M1.jar
transactions-api-3.9.0.M1.jar
transactions-jdbc-3.9.0.M1.ja
transactions-jms-3.9.0.M1.jar
transactions-jta-3.9.0.M1.jar
相关推荐
本篇文章将深入探讨如何在Spring框架中结合Mybatis和Atomikos进行分布式事务管理的配置与集成。Atomikos是一款强大的开源事务处理系统,它支持JTA(Java Transaction API),可以为我们的应用程序提供分布式事务解决...
Atomikos分布式事务DEMO是一个基于Spring、MyBatis、MySQL和Tomcat的示例项目,主要用于演示和验证分布式事务的处理能力。分布式事务在现代企业级应用中扮演着重要角色,尤其是在处理跨多个数据库或服务的数据一致性...
Spring 中使用 Atomikos+Druid 实现经典分布式事务的方法 在分布式系统中,经典分布式事务是相对互联网中的柔性分布式事务而言,其特性为 ACID 原则,包括原子性(Atomictiy)、一致性(Consistency)、隔离性...
- 使用 MyBatis 分布式事务,需要额外的分布式事务协调器,如 Atomikos、Bitronix 等。 5. **事务回滚规则**: - 默认情况下,MyBatis 在遇到运行时异常时会回滚事务,非运行时异常(检查异常)则不会。 - 可以...
5. **异常处理**:在分布式事务中,必须处理可能出现的事务异常,如HeuristicCompletionException、SystemException等。Spring提供了TransactionTemplate和PlatformTransactionManager接口,便于捕获和处理这些异常...