使用atomikos时,事务默认超时时间是100000毫秒,超过这个时间,提交事务就会抛出异常

nested exception is javax.transaction.RollbackException: Prepare: NO vote

1、增加配置文件transactions.properties(jta.properties)

需要在classpath下建一个transactions.properties(或者jta.properties)文件(事务管理器的配置),来配置事务相关属性,如下是我的transactions.properties

# SAMPLE PROPERTIES FILE FOR THE TRANSACTION SERVICE
# THIS FILE ILLUSTRATES THE DIFFERENT SETTINGS FOR THE TRANSACTION MANAGER
# UNCOMMENT THE ASSIGNMENTS TO OVERRIDE DEFAULT VALUES;# Required: factory implementation class of the transaction core.
# NOTE: there is no default for this, so it MUST be specified!
#
com.atomikos.icatch.service=com.atomikos.icatch.standalone.UserTransactionServiceFactory
#com.atomikos.icatch.max_timeout=2000# Set base name of file where messages are output
# (also known as the 'console file').
#
# com.atomikos.icatch.console_file_name = tm.out# Size limit (in bytes) for the console file;
# negative means unlimited.
#
# com.atomikos.icatch.console_file_limit=-1# For size-limited console files, this option
# specifies a number of rotating files to
# maintain.
#
# com.atomikos.icatch.console_file_count=1# Set the number of log writes between checkpoints
#
# com.atomikos.icatch.checkpoint_interval=500# Set output directory where console file and other files are to be put
# make sure this directory exists!
#
# com.atomikos.icatch.output_dir = ./# Set directory of log files; make sure this directory exists!
#
# com.atomikos.icatch.log_base_dir = ./# Set base name of log file
# this name will be  used as the first part of
# the system-generated log file name
#
# com.atomikos.icatch.log_base_name = tmlog# Set the max number of active local transactions
# or -1 for unlimited.
#
# com.atomikos.icatch.max_actives = 50# Set the default timeout (in milliseconds) for local transactions
#
# com.atomikos.icatch.default_jta_timeout = 10000# Set the max timeout (in milliseconds) for local transactions
#
# com.atomikos.icatch.max_timeout = 300000# The globally unique name of this transaction manager process
# override this value with a globally unique name
#
# com.atomikos.icatch.tm_unique_name = tm# Do we want to use parallel subtransactions? JTA's default
# is NO for J2EE compatibility
#
#com.atomikos.icatch.serial_jta_transactions=false# If you want to do explicit resource registration then
# you need to set this value to false.
#
# com.atomikos.icatch.automatic_resource_registration=true# Set this to WARN, INFO or DEBUG to control the granularity
# of output to the console file.
#
# com.atomikos.icatch.console_log_level=WARN# Do you want transaction logging to be enabled or not?
# If set to false, then no logging overhead will be done
# at the risk of losing data after restart or crash.
#
# com.atomikos.icatch.enable_logging=true# Should two-phase commit be done in (multi-)threaded mode or not?
# Set this to false if you want commits to be ordered according
# to the order in which resources are added to the transaction.
#
# NOTE: threads are reused on JDK 1.5 or higher.
# For JDK 1.4, thread reuse is enabled as soon as the
# concurrent backport is in the classpath - see
# http://mirrors.ibiblio.org/pub/mirrors/maven2/backport-util-concurrent/backport-util-concurrent/
#
# com.atomikos.icatch.threaded_2pc=false# Should shutdown of the VM trigger shutdown of the transaction core too?
#
# com.atomikos.icatch.force_shutdown_on_vm_exit=false
# 配置最大的事务活动个数,-1代表无限制(atomikos版本3.9.3)
com.atomikos.icatch.max_actives = -1
# 默认的超时时间单位毫秒
com.atomikos.icatch.default_jta_timeout = 3000000# Set the max timeout (in milliseconds) for local transactions
# 0不起作用(网上有很多说将这个配置成0表示无限制,但是我配置后还是会报com.atomikos.icatch.RollbackException: Prepare: NO vote可能是atomikos版本不一样的缘故吧 我用的版本是3.9.3)所以我将其配置成大于0的数
com.atomikos.icatch.max_timeout = 3000000

2、修改spring-**.xml文件

这个文件是spring的配置文件名字叫什么都可以

(1)<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"init-method="init" destroy-method="close"><property name="forceShutdown"><!-- 将close()时是否强制终止事务设置为false-->        <value>false</value></property>
</bean>

(2)

<bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp"><!--将该属性注释掉 <property name="transactionTimeout" value="5000" />-->
</bean>

我通过以上配置后atomikos事务提交正常

解决多数据事务提交异常nested exception is javax.transaction.RollbackException: Prepare: NO vote,atomikos版本3.9.3相关推荐

  1. nested exception is javax.persistence.RollbackException: Error while commiting the transaction

    org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested ...

  2. 解决spring boot项目中Caused by: com.atomikos.icatch.RollbackException: Prepare: NO vote异常

    项目使用 spring boot 框架构建,持久层使用 hibernate,用 atomikos 做分布式事务管理,今天在写一个业务时,因为是需要从腾讯地图api接口拿到数据循环保存到自己本地库中,所 ...

  3. 使用atomikos分布式事务报com.atomikos.icatch.RollbackException: Prepare: NO vote异常解决办法

    发现后台使用atomikos进行事务提交时报javax.transaction.RollbackException: Prepare: NO vote,造成这个事务的主要原因是使用atomikos时, ...

  4. result returns more than one elements; nested exception is javax.persistence.NonUniqueResultExceptio

    解决:result returns more than one elements; nested exception is javax.persistence.NonUniqueResultExcep ...

  5. Executing an update/delete query; nested exception is javax.persistence.TransactionRequiredException

    Executing an update/delete query; nested exception is javax.persistence.TransactionRequiredException ...

  6. 解决Hander dispatch failed;nested exception is java .lang. AbstractMethodError:Method com/mchange/v2/c

    解决Hander dispatch failed;nested exception is java .lang. AbstractMethodError:Method com/mchange/v2/c ...

  7. 解决bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符

    前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. 1. 报错: ### Cause: java.sql.SQLSyntaxErrorException ...

  8. 解决Request processing failed; nested exception is com.sun.jersey.api.client.UniformInterfaceException

    跨服务器上传图片时遇到如下错误: Request processing failed; nested exception is com.sun.jersey.api.client.UniformInt ...

  9. 关于异常nested exception is java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactor

    简单看了一下发现原来是没有commons-fileupload包导致的,然后就在pom里加入了依赖. <dependency><groupId>commons-fileuplo ...

最新文章

  1. SAP QM维护检验计划指派取样策略时候报错:Sampling procedure is not permitted for insp.point-related inspection
  2. OpenCV 1.x 2.x 编程简介(矩阵/图像/视频的基本读写操作)
  3. redis 模糊查找keys
  4. 如何获得onblur中的值_使用带有onBlur的输入字段和来自Reactjs JSX中的状态块输入的值?...
  5. Linux查找(find)指令的使用
  6. 用python开启相机_使用“打开”编辑相机设置
  7. javascript:鼠标拖动图标技术
  8. 计算机程序设计流程图循环,流程图循环画法_流程图用什么办公软件
  9. 我的时间管理类培训PPT
  10. 基于VUE技术的超市购物系统设计答辩PPT模板
  11. 拼多多商家如何采集整店商品上传?
  12. 计算机界面视频录制软件,视频录制工具怎么用?这样的电脑录屏方法超实用!...
  13. Dreamweaver CS6破解教程[序列号+破解补丁
  14. Firefox 浏览器和burp suit 证书配置
  15. 见证一张CAD图如何蜕变成一个高大上的三维地形模型(一)
  16. android客户端功能,推荐一个功能齐全的【玩Android客户端】
  17. stormzhang的自我介绍
  18. MATLAB初阶绘图
  19. 华为S系列交换机修改密码不成功
  20. html 自动填表,Delphi WEB网页自动填表

热门文章

  1. 蓝信在小程序袭来的5G时代如何应对
  2. 小程序的拖拽、缩放和旋转手势
  3. Spark:Jieba对数据库里提取的记录进行中文分词
  4. 第八期 RT3052F芯片分析 《路由器就是开发板》
  5. 〖大前端 - 基础入门三大核心之 html 篇⑧〗- 无序列表
  6. 【JVM】VM是什么?JVM是什么?JVM作用是什么?JVM特点?JVM位置?JVM组成?
  7. Word控件Spire.Doc 【Table】教程(1):在 Word 中创建表格-C#VB.NET
  8. 天池目标检测比赛入门
  9. Resume In English
  10. BI Publiser bursting 邮件附件名称乱码问题