jta

Wildfly 8.0.0.Final JTA transaction issues

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Since we use a lot of @ApplicationScoped beans with transaction but we do not want to use EJBs (ApplicationScoped bean does not work with stateless beans), we create our own transaction interceptor such as: @Resource UserTransaction tx; @Resource(mappedName="java:jboss/TransactionSynchronizationRegistry") TransactionSynchronizationRegistry tsr; @AroundInvoke public Object manageTransaction(InvocationContext context) throws Exception { Object result; if (Status.STATUS_NO_TRANSACTION == tsr.getTransactionStatus()) { tx.begin(); // System.out

Spring JTA TransactionManager config: Supporting both Tomcat and JBoss

我们两清 提交于 2019-12-02 23:53:15
I have a web application using JPA and JTA with Spring. I would like to support both JBoss and Tomcat. When running on JBoss, I'd like to use JBoss' own TransactionManager, and when running on Tomcat, I'd like to use JOTM. I have both scenarios working, but I now find that I seem to need two separate Spring configurations for the two cases. With JOTM, I need to use Spring's JotmFactoryBean : <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> <property name="userTransaction"> <bean class="org.springframework.transaction.jta.JotmFactoryBean"/> <

搭建Spring Initializr服务器

匿名 (未验证) 提交于 2019-12-02 21:52:03
前言 按照网上很多教程,出错特别多。首先是GitHub和maven仓库的网络环境比较差,踩了很多坑;其次是SpringInitializr更新迭代几个版本,0.7.0我也没能弄成功。索性就用了旧版本0.6.0 一、运行环境 Maven版本:3.5.3 JDK:1.8 Windows:win7 x64 Spring Initilizr版本:v0.6.0 二、设置使用阿里的maven仓库 maven安装目录中,conf文件夹下settings配置文件mirrors节点增加以下子节点: <mirror> <id>nexus-aliyun</id> <mirrorOf>central</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror> 三、下载并编译SpringInitializr (一)下载源码 git或者其他方式下载,主页: https://github.com/spring-io/initializr https://github.com/spring-io/initializr/releases 下载了zip (二)编译 试了网上很多mvnw clean install或者mvn clean install的命令

Spring Transactions - Prevent rollback after unchecked exceptions (RuntimeException)

随声附和 提交于 2019-12-01 22:39:14
I can't manage to prevent a transaction from rollingback after a RuntimeException. My env is Spring 4.1 + Hibernate 3.6 + JTA (WebSphereUowTransactionManager) running on Websphere 8.0. First off, a simple case that behaves as expected. Since I catch the RuntimeException , the transaction commits and the new resource is created successfully. @Service("fooService") public class FooServiceImpl implements IFooService { @Transactional @Override public void doStuff(Resource res){ authService.createResource(res, "ADMIN"); try { throw new RuntimeException("SOMETHING"); } catch (RuntimeException e) { e

WebLogic11g-配置数据源及JTA

自闭症网瘾萝莉.ら 提交于 2019-12-01 21:06:10
这篇文章依然以Springside3的mini-web为例(数据库采用oracle) 一、使用WebLogic的dataSource获取数据库连接 1、介绍WebLogic11g的数据源配置: 1)启动domain服务,登录控制台(具体可参考前两篇),点击域结构-》服务-》数据源,如下图所示: 2)新建数据源: 点击新建-》一般数据源,输入数据源显示名称,及jndi名称,数据库类型(这里以oracle为例,如下图所示: 输入完成,点击下一步。 3)选择数据库驱动程序: 注意:Thin XA表示支持全局事务。这里,我们选择第一个驱动程序,点击下一步。 4)事务处理选项: 如图所示,由于我们选择了XA驱动,所以这里只是告知你的数据源支持全局事务。如果不是XA驱动,这里会让你选择相关事务处理方式。点击下一步继续。 5)配置数据源连接参数: 如果所示,输入数据库名称、主机名、端口默认1521、数据库用户名、口令,没什么好说的,点击下一步 6)测试数据源配置: 如图所示,点击测试配置,如果配置正常,会显示“连接测试成功”,如果配置有问题,这里会提示失败错误。如果成功的话,点击下一步继续。 7)选择目标: 如图所示,这里会列出当前domain下面的所有服务器列表,意思就是说,你这个数据源提供给哪些服务器使用。【如果是非集群环境,这里就一个adminserver,选中即可。如果是集群环境

Spring Transactions - Prevent rollback after unchecked exceptions (RuntimeException)

我怕爱的太早我们不能终老 提交于 2019-12-01 19:21:08
问题 I can't manage to prevent a transaction from rollingback after a RuntimeException. My env is Spring 4.1 + Hibernate 3.6 + JTA (WebSphereUowTransactionManager) running on Websphere 8.0. First off, a simple case that behaves as expected. Since I catch the RuntimeException , the transaction commits and the new resource is created successfully. @Service("fooService") public class FooServiceImpl implements IFooService { @Transactional @Override public void doStuff(Resource res){ authService

终于有人把“分布式事务”说清楚了!

99封情书 提交于 2019-12-01 11:11:51
1、分布式事务 高可用是指系统无中断的执行功能的能力,代表了系统的可用程度,是进行系统设计时必须要遵守的准则之一。 而高可用的实现方案,无外乎就是冗余,就存储的高可用而言,问题不在于如何进行数据备份,而在于如何规避数据不一致对业务造成的影响。 对于分布式系统而言,要保证分布式系统中的数据一致性就需要一种方案,可以保证数据在子系统中始终保持一致,避免业务出现问题。 这种实现方案就叫做分布式事务,要么一起成功,要么一起失败,必须是一个整体性的事务。 针对分布式系统的特点,基于不同的一致性需求产生了不同的分布式事务解决方案, 追求强一致的两阶段提交、追求最终一致性的柔性事务和事务消息 等等。各种方案没有绝对的好坏,抛开具体场景我们无法评价,更无法能做出合理选择。在选择分布式事务方案时,需要我们充分了解各种解决方案的原理和设计初衷,再结合实际的业务场景,从而做出科学合理的选择。 2、理论基础 在讲解具体方案之前,有必要了解一下分布式中数据设计需要遵循的理论基础,CAP 理论和 BASE 理论,为后面的实践铺平道路。 2.1 CAP 理论 CAP,Consistency Availability Partition tolerance 的简写: Consistency: 一致性,对某个客户端来说,读操作能够返回最新的写操作结果。 Availability: 可用性

How to get Hibernate configuration properties?

匆匆过客 提交于 2019-12-01 11:03:46
I`m using hibernate with jpa, and it is configured with persistence.xml Is it possible to get hibernate connection properties from web application? Thanks. Probably not without using reflection and relying on the Hibernate not to break your code in the future. You need to get the properties from the SessionFactory but it's not public so you would have to find the Field via reflection, then use field.setAccessibleto get access to it. Something like: Field f = SessionFactoryImpl.class.getDeclaredField("properties"); f.setAccessible(true); Properties p = (Properties)f.get(sessionFactory); Then

Spring + Hibernate +JTA - HibernateTransactionManager or JTATransactionManager

主宰稳场 提交于 2019-12-01 09:34:17
I want to Integrate Spring and Hibernate and use JTA for managing the transactions. I would also like to delegate transaction handling to the App server, which in my case is JBoss. I have a query regarding the configuration of the " transactionManager " bean in Spring: 1) Can we use HibernateTransactionManager and set the the properties hibernate.transaction.factory_class and hibernate.transaction.manager_lookup_class in hibernate.properties file? If not, why? 2) Or, should we use JTATransactionManager ? In option (2), do we still need to set the properties("hibernate.transaction.factory_class

change jta transaction timeout from default to custom

霸气de小男生 提交于 2019-12-01 06:43:49
I am using Atomikos for JTA transaction. I have following setting for JTA: UserTransactionImp userTransactionImp = new UserTransactionImp(); userTransactionImp.setTransactionTimeout(900); but when my code perform JTA transaction, then if it takes more than 5 minutes (which is default value) then it throws exception: Caused by: com.atomikos.icatch.RollbackException: Prepare: NO vote at com.atomikos.icatch.imp.ActiveStateHandler.prepare(ActiveStateHandler.java:231) at com.atomikos.icatch.imp.CoordinatorImp.prepare(CoordinatorImp.java:681) at com.atomikos.icatch.imp.CoordinatorImp.terminate