问题描述
大家好我做了一个应用程序配置使用jsf,spring 3.0,hybernate + JPA和atomikos进行XA Transcation管理,而mysql是我的后端,这里每个东西都工作正常但是插入操作,当异常抛出transcation时应该回滚,但它没有发生!这里是我们的应用i的一个小流程,使用jsfmanagedbean来调用我的服务,从我的服务类我的transcation将开始
TextileUIBean.java
package com.textile.web;
public class TextileUIBean extends BaseManagedBean implements Serializable,
{
public insertPaymentDetails()
{
PaymentDetails PaymentDetails = new PaymentDetails();
//值是硬编码,只有两个propereties只使用
PaymentDetails.setCustomerName(Manikandan);
PaymentDetails.setAmount(1000);
getTextileManager()。insertPaymentDetails(PaymentDetails);
$ b $ public ITextileManager getTextileManager(){
textileManager =(ITextileManager)getBean(textileManager);
返回textileManager;
}
}
服务类别
package com .textile.web
public interface ITextileManager
{
public void insertPaymentDetails(PaymentDetails PaymentDetails);
package com.textile.web
public class TextileManager实现ITextileManager
{
ITextileBusiness TextileBusiness;
public void setTextileBusiness(ITextileBusiness textileBusiness){
this.textileBusiness = textileBusiness;
}
void insertPaymentDetails(PaymentDetails PaymentDetails)
{
TextileBusiness.insertPaymentDetails(PaymentDetails);
}
和我的商务舱是
包com.textile.web
public interface ITextileBusiness
{
public void insertPaymentDetails(PaymentDetails PaymentDetails);
包com.textile.web
公共类TextileBusiness实现ITextileBusiness
{
ITextileDao textileDao;
public void setTextileDao(ITextileDao textileDao){
this.textileDao = textileDao;
}
void insertPaymentDetails(PaymentDetails ormPaymentTable)
{
OrmPaymentTable ormPaymentTable = OrmPaymentTable();
ormPaymentTable.setCustomerName(PaymentDetails.getCustomerName());
ormPaymentTable.setAmount(PaymentDetails.getAmount(););
textileDao.insertPaymentDetails(ormPaymentTable);
int a = 0;
if(a == 0)
throw new BusinessException(Transcation Rollback);
}
}
和我的dao类是
package com.textile.web
public interface IPaymentsDao {
public void insertPaymentDetails(OrmPaymentTable ormPaymentTable);
}
package com.textile.web
public class PaymentsDao implements IPaymentsDao
{
void insertPaymentDetails(OrmPaymentTable ormPaymentTable)
{
this。 getJpaTemplate()持续(ormPaymentTable)。
在此行之后,记录被插入表中
}
}
我的FacesConfig.xml是
< application>
< el-resolver> org.springframework.web.jsf.el.SpringBeanFacesELResolver< / el-resolver>
< locale-config>
< default-locale> en< / default-locale>
< supported-locale> en< / supported-locale>
< / locale-config>
< message-bundle>消息< / message-bundle>
< / application>
< managed-bean> <托管bean-名称>&textileUIBean LT; /托管bean-名称> <托管bean级> com.textile.web.TextileUIBean< /托管bean级>
< managed-bean-scope>视图< / managed-bean-scope>
< / managed-bean>
和我的applicationConfig.xml文件是
< beans:bean id =dataSource
class =org.springframework.jndi.JndiObjectFactoryBean>
< beans:property name =jndiName>
< beans:value> java:comp / env / jdbc / textWeb< / beans:value>
< / beans:property>
< beans:property name =resourceRef>
< beans:value> true< / beans:value>
< / beans:property>
< / beans:bean>
< beans:bean id =jpaTemplateclass =org.springframework.orm.jpa.JpaTemplate>
< beans:property name =entityManagerFactory>
< beans:ref bean =entityManagerFactory/>
< / beans:property>
< / beans:bean>
< beans:bean id =entityManagerFactory
class =org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean>
< beans:property name =dataSource>
< beans:ref bean =dataSource/>
< / beans:property>
< beans:property name =persistenceUnitNamevalue =payhub/>
< beans:property name =jpaVendorAdapter>
< beans:bean
class =org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter>
< beans:property name =generateDdlvalue =false/>
< beans:property name =showSqlvalue =true/>
< beans:property name =databasePlatformvalue =$ {database.target}/>
< / beans:bean>
< / beans:property>
< beans:property name =persistenceXmlLocation>
< beans:value> classpath:META-INF / persistence.xml< / beans:value>
< / beans:property>
< / beans:bean>
< beans:bean id =textileManager
class =com.textile.web.TextileManager>
< beans:property name =textileBusinessref =textileBusiness/>
< / beans:bean>
< beans:bean id =textileBusinessclass =com.textile.web.TextileBusiness>
< beans:property name =textileDaoref =textileDao/>
< / beans:bean>
< beans:bean id =textileDaoclass =com.textile.web.textileDao>
< beans:property name =jpaTemplate>
< beans:ref bean =jpaTemplate/>
< / beans:property>
< / beans:bean>
< aop:config>
< aop:pointcut id =fooServiceOperationexpression =execution(* com.textile.web。*。*(..))/>
< / aop:config>
< tx:advice id =txAdvicetransaction-manager =transactionManager>
< tx:attributes>
< tx:method name =*propagation =REQUIRED/>
< / tx:属性>
< / tx:advice>
class =com.atomikos.icatch.jta.UserTransactionManagerinit-method =init
destroy-method = 接近 >
< beans:property name =forceShutdownvalue =true/>
< beans:property name =startupTransactionServicevalue =true/>
< / beans:bean>
< bean:bean id =atomikosUserTransactionclass =com.atomikos.icatch.jta.UserTransactionImp>
< beans:property name =transactionTimeout>
< beans:value> 3000< / beans:value>
< / beans:property>
< / beans:bean>
< beans:bean id =transactionManager
class =org.springframework.transaction.jta.JtaTransactionManager>
< beans:property name =transactionManager>
< beans:ref bean =atomikosTransactionManager/>
< / beans:property>
< beans:property name =userTransaction>
< beans:ref bean =atomikosUserTransaction/>
< / beans:property>
< beans:property name =rollbackOnCommitFailurevalue =true>
< / beans:property>
< / beans:bean>
$ b和orm.xml文件是
< entity class =OrmPaymentTablename =OrmPaymentTable>
< table name =ta_payment/>
<属性>
< id name =paymentId>
< column name =USER_ID/>
< generated-value strategy =AUTO/>
< / id>
< basic name =customerName>
< column name =CUST_NAMElength =50/>
< / basic>
< basic name =amount>
< column name =AMOUNTlength =50/>
< / basic>
< / attributes>
< / entity>
< persistence-unit name =payhubtransaction-type =JTA>
< provider> org.hibernate.ejb.HibernatePersistence< / provider>
< jta-data-source> java:comp / env / jdbc / textWeb< / jta-data-source>
< mapping-file> META-INF / orm.xml< / mapping-file>
< class> com.textile.web.OrmPaymentTable< / class>
<属性>
< property name =hibernate.transaction.manager_lookup_class
value =com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup/>
< property name =hibernate.transaction.factory_class
value =org.hibernate.transaction.JTATransactionFactory/>
< / properties>
< / persistence-unit>
< /余辉>
我在meta-inf / context.xml中配置jndi
<上下文>
< Transaction factory =com.atomikos.icatch.jta.UserTransactionFactory/>
< Resource name =jdbc / textWebauth =Container
driverClassName =com.mysql.jdbc.Driveruser =rootpassword =root
type = com.mysql.jdbc.jdbc2.optional.MysqlXADataSourcefactory =com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory
url =jdbc:mysql:// localhost:3306 / textWebexplicitUrl =真
pinGlobalTxToPhysicalConnection =true>
< /资源>
< / Context>
web.xml
< resource-ref>
< description> PaymentsDatabase< / description>
< res-ref-name> jdbc / textWeb< / res-ref-name>
< res-type> javax.sql.DataSource< / res-type>
< res-auth>容器< / res-auth>
< res-sharing-scope>可分享< / res-sharing-scope>
< / resource-ref>
我追踪日志..查看我的日志记录详情
78 [main] INFO atomikos - USING core版本:3.6.4
78 [main] INFO atomikos - USING com.atomikos.icatch.console_file_name = tm。 out
78 [main] INFO atomikos - USING com.atomikos.icatch.console_file_count = 1
78 [main] INFO atomikos - USING com.atomikos.icatch.automatic_resource_registration = true
78 [main ] INFO atomikos - USING com.atomikos.icatch.client_demarcation = false
78 [main] INFO atomikos - USING com.atomikos.icatch.threaded_2pc = true
78 [main] INFO atomikos - USING com.atomikos .icatch.serial_jta_transactions = false
78 [main] INFO atomikos - USING com.atomikos.icatch.log_base_dir = .\
94 [main] INFO atomikos - USING com.atomikos.icatch.console_log_level = WARN
94 [main] INFO atomikos - USING com.atomikos.icatch.max_actives = 50
94 [main] INFO atomikos - USING com.atomikos.icatch.checkpoint_interval = 500
94 [main] INFO atomikos - USING com.atomikos.icatch.enable_logging = false
94 [main] INFO atomikos - USING com.atomikos.icatch.output_dir = .\
94 [main] INFO atomikos - USING com.atomikos.icatch.log_base_name = tmlog
94 [main] INFO atomikos - USING com.atomikos.icatch.console_file_limit = 0
94 [main] INFO atomikos - USING com.atomikos.icatch.max_timeout = 300000
94 [main] INFO atomikos - USING com.atomikos.icatch.tm_unique_name = PaymentsTransactions
94 [main] INFO atomikos - USING java.naming.factory.initial = com.sun.jndi.rmi .registry.RegistryContextFactory
94 [main] INFO atomikos - 使用java.naming.provider.url = rmi:// localhost:1099
94 [main] INFO atomikos - USING com.atomikos.icatch.service = com.atomikos.icatch.standalone.UserTransactionServiceFactory
94 [main] INFO atomikos - USING com.atomikos.icatch.force_shutdown_on_vm_exit = false
94 [main] INFO atomikos - USING com.atomikos.icatch.default_jta_timeout = 10000
INFO - JtaTransactionManager.checkUserTransactionAndTransactionManager(469)|使用JTA UserTransaction:com.atomikos.icatch.jta.UserTransactionImp@16a6027
INFO - JtaTransactionManager.checkUserTransactionAndTransactionManager(480)|使用JTA TransactionManager:com.atomikos.icatch.jta.UserTransactionManager@e68513
DEBUG - NameMatchTransactionAttributeSource.addTransactionalMethod(94)|使用属性[PROPAGATION_REQUIRED,ISOLATION_DEFAULT]添加事务性方法[*]
DEBUG - AbstractPlatformTransactionManager.getTransaction(365)|使用名称[com.evolvus.payments.manager.IPaymentsManager.findColumnChartDisplayByGateWays]创建新事务:PROPAGATION_REQUIRED,ISOLATION_DEFAULT
40500 [http-8080-Processor24]警告atomikos - 尝试创建超过com.atomikos的事务.icatch.max_timeout - 截断为:300000
40641 [http-8080-Processor24] INFO atomikos - THREADS:使用JDK线程池...
40703 [http-8080-Processor24] INFO atomikos - createCompositeTransaction 3000000):使用ID创建新的ROOT交易PaymentsTransactions0000100688
DEBUG - AbstractPlatformTransactionManager.handleExistingTransaction(470)|参与现有的事务
DEBUG - AbstractPlatformTransactionManager.handleExistingTransaction(470)|参与现有的事务
DEBUG - AbstractPlatformTransactionManager.processRollback(850)|参与交易失败 - 将现有交易标记为仅回滚
DEBUG - JtaTransactionManager.doSetRollbackOnly(1060)|设置JTA事务仅回滚
49110 [http-8080-Processor24] INFO atomikos - setRollbackOnly()调用事务PaymentsTransactions0000100688
DEBUG - AbstractPlatformTransactionManager.processRollback(843)|启动事务回滚
49172 [http-8080-Processor24]信息atomikos - afterCompletion(STATUS_ROLLEDBACK)调用同步:org.hibernate.transaction.CacheSynchronization
49172 [http-8080-Processor24] INFO atomikos - afterCompletion STATUS_ROLLEDBACK)调用同步:org.hibernate.ejb.EntityManagerImpl$1@1f6e48a
49172 [http-8080-Processor24] INFO atomikos - rollback()完成事务PaymentsTransactions0000100688
你能帮助我吗?
很明显,您的数据库插入不会发生在您的事务管理器当前事务的范围内。
一些想法:
1)也许它不在您的发布中,但我没有在您的服务中看到Spring @Transactional注释类。 2)因为你使用的是JNDI,所以我们看不到你的数据源,但是如果你使用的是Atomikos,你应该使用他们的XA感知池数据源。 3)您应该将Atomikos正常日志记录增加到DEBUG中,以确切查看它正在处理的SQL命令。
4)Atomikos保留在正常日志文件之外的事务日志。这些用于恢复和其他目的。你也应该检查这些线索。
希望这有助于您。
更新: b
MySQL对XA事务有一些限制,您可以在这里关于。在你的context.xml中尝试这个配置,至少看看它是否工作。它使用Atomikos提供的XA(但不支持XA)数据源。如果这样做,那么你可以从那里去:
< Transaction factory =com.atomikos.icatch.jta.UserTransactionFactory/>
以及定义注入实体管理器的JNDI数据源:
< Resource name =jdbc / myDataSourceauth =Container
factory =org.apache.naming.factory.BeanFactory
type =com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean
uniqueResourceName =myMySqlDatabasedriverClassName =com.mysql.jdbc.Driver
url =......user =.....password =....
maxPoolSize =20reapTimeout =300/>
Hi all I have done an application configuration using jsf ,spring 3.0,hybernate + JPA and atomikos for XA transcation management and mysql is my backend,here every thing is working fine however insert operation, when exception is throwing the transcation should rollback,but it is not happening!! here is a small flow for our application i am using jsfmanagedbean to cal my servive,from my service class my transcation will start
TextileUIBean.java
package com.textile.web; public class TextileUIBean extends BaseManagedBean implements Serializable, { public insertPaymentDetails() { PaymentDetails PaymentDetails=new PaymentDetails(); // values are hard coded ans only two propereties only using PaymentDetails.setCustomerName("Manikandan"); PaymentDetails.setAmount(1000); getTextileManager().insertPaymentDetails(PaymentDetails); } public ITextileManager getTextileManager() { textileManager = (ITextileManager) getBean("textileManager"); return textileManager; } }
service class
package com.textile.web
public interface ITextileManager
{
public void insertPaymentDetails(PaymentDetails PaymentDetails);
}
package com.textile.web
public class TextileManager implements ITextileManager
{
ITextileBusiness TextileBusiness ;
public void setTextileBusiness(ITextileBusiness textileBusiness) {
this.textileBusiness = textileBusiness;
}
void insertPaymentDetails(PaymentDetails PaymentDetails)
{
TextileBusiness.insertPaymentDetails(PaymentDetails);
}
and my business class is
package com.textile.web
public interface ITextileBusiness
{
public void insertPaymentDetails(PaymentDetails PaymentDetails);
}
package com.textile.web
public class TextileBusiness implements ITextileBusiness
{
ITextileDao textileDao;
public void setTextileDao(ITextileDao textileDao) {
this.textileDao = textileDao;
}
void insertPaymentDetails(PaymentDetails ormPaymentTable)
{
OrmPaymentTable ormPaymentTable= OrmPaymentTable();
ormPaymentTable.setCustomerName(PaymentDetails.getCustomerName());
ormPaymentTable.setAmount(PaymentDetails.getAmount(););
textileDao.insertPaymentDetails(ormPaymentTable);
int a=0;
if(a==0)
throw new BusinessException("Transcation Rollback");
}
}
and my dao class is
package com.textile.web
public interface IPaymentsDao {
public void insertPaymentDetails(OrmPaymentTable ormPaymentTable);
}
package com.textile.web
public class PaymentsDao implements IPaymentsDao
{
void insertPaymentDetails(OrmPaymentTable ormPaymentTable)
{
this.getJpaTemplate().persist(ormPaymentTable);
after this line the record is insertinf into table
}
}
my FacesConfig.xml is
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>en</supported-locale>
</locale-config>
<message-bundle>Messages</message-bundle>
</application>
<managed-bean> <managed-bean-name>textileUIBean</managed-bean-name> <managed-bean-class>com.textile.web.TextileUIBean</managed-bean-class>
<managed-bean-scope>view</managed-bean-scope>
</managed-bean>
and my applicationConfig.xml file is
<beans:bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean" >
<beans: property name="jndiName">
<beans: value>java:comp/env/jdbc/textWeb</beans:value>
</beans: property>
<beans: property name="resourceRef">
<beans:value>true</beans:value>
</beans: property>
</beans: bean>
<beans: bean id="jpaTemplate" class="org.springframework.orm.jpa.JpaTemplate">
<beans: property name="entityManagerFactory">
<beans: ref bean="entityManagerFactory" />
</beans: property>
</beans: bean>
<beans: bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<!-- hidden by shiju because we need one datasource support its in prsistence.xml !-->
<beans: property name="dataSource">
<beans: ref bean="dataSource" />
</beans: property>
<beans: property name="persistenceUnitName" value="payhub" />
<beans: property name="jpaVendorAdapter">
<beans:bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<beans: property name="generateDdl" value="false" />
<beans: property name="showSql" value="true" />
<beans: property name="databasePlatform" value="${database.target}" />
</beans: bean>
</beans: property>
<beans: property name="persistenceXmlLocation">
<beans: value>classpath:META-INF/persistence.xml</beans:value>
</beans: property>
</beans: bean>
<beans:bean id="textileManager"
class=" com.textile.web.TextileManager">
<beans: property name="textileBusiness" ref="textileBusiness" />
</beans: bean>
<beans: bean id="textileBusiness" class="com.textile.web.TextileBusiness">
<beans: property name="textileDao" ref="textileDao" />
</beans: bean>
<beans: bean id="textileDao" class="com.textile.web.textileDao">
<beans: property name="jpaTemplate">
<beans: ref bean="jpaTemplate"/>
</beans: property>
</beans: bean>
<aop:config>
<aop:pointcut id="fooServiceOperation" expression="execution(* com.textile.web.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="fooServiceOperation"/>
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<beans: bean id="atomikosTransactionManager"
class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init"
destroy-method="close">
<beans: property name="forceShutdown" value="true" />
<beans: property name="startupTransactionService" value="true" />
</beans:bean>
<beans:bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
<beans: property name="transactionTimeout">
<beans: value>3000</beans:value>
</beans: property>
</beans:bean>
<beans: bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<beans: property name="transactionManager">
<beans: ref bean="atomikosTransactionManager" />
</beans: property>
<beans: property name="userTransaction">
<beans: ref bean="atomikosUserTransaction"/>
</beans: property>
<beans: property name="rollbackOnCommitFailure" value="true">
</beans: property>
</beans: bean>
and orm.xml file is
<entity class="OrmPaymentTable" name="OrmPaymentTable">
<table name="ta_payment" />
<attributes>
<id name="paymentId">
<column name="USER_ID" />
<generated-value strategy="AUTO" />
</id>
<basic name="customerName">
<column name="CUST_NAME" length="50" />
</basic>
<basic name="amount">
<column name="AMOUNT" length="50" />
</basic>
</attributes>
</entity>
<persistence-unit name="payhub" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:comp/env/jdbc/textWeb</jta-data-source>
<mapping-file>META-INF/orm.xml</mapping-file>
<class>com.textile.web.OrmPaymentTable</class>
<properties>
<property name="hibernate.transaction.manager_lookup_class"
value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup"/>
<property name="hibernate.transaction.factory_class"
value="org.hibernate.transaction.JTATransactionFactory" />
</properties>
</persistence-unit>
</persistence>
and i configure jndi in meta-inf/context.xml
<Context>
<Transaction factory="com.atomikos.icatch.jta.UserTransactionFactory"/>
<Resource name="jdbc/textWeb" auth="Container"
driverClassName="com.mysql.jdbc.Driver" user="root" password="root"
type="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" factory="com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory"
url="jdbc:mysql://localhost:3306/textWeb" explicitUrl="true"
pinGlobalTxToPhysicalConnection="true">
</Resource>
</Context>
web.xml
<resource-ref>
<description>PaymentsDatabase</description>
<res-ref-name>jdbc/textWeb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
I trace the log.. see my transcation log details
78 [main] INFO atomikos - USING core version: 3.6.4
78 [main] INFO atomikos - USING com.atomikos.icatch.console_file_name = tm.out
78 [main] INFO atomikos - USING com.atomikos.icatch.console_file_count = 1
78 [main] INFO atomikos - USING com.atomikos.icatch.automatic_resource_registration = true
78 [main] INFO atomikos - USING com.atomikos.icatch.client_demarcation = false
78 [main] INFO atomikos - USING com.atomikos.icatch.threaded_2pc = true
78 [main] INFO atomikos - USING com.atomikos.icatch.serial_jta_transactions = false
78 [main] INFO atomikos - USING com.atomikos.icatch.log_base_dir = .\
94 [main] INFO atomikos - USING com.atomikos.icatch.console_log_level = WARN
94 [main] INFO atomikos - USING com.atomikos.icatch.max_actives = 50
94 [main] INFO atomikos - USING com.atomikos.icatch.checkpoint_interval = 500
94 [main] INFO atomikos - USING com.atomikos.icatch.enable_logging = false
94 [main] INFO atomikos - USING com.atomikos.icatch.output_dir = .\
94 [main] INFO atomikos - USING com.atomikos.icatch.log_base_name = tmlog
94 [main] INFO atomikos - USING com.atomikos.icatch.console_file_limit = 0
94 [main] INFO atomikos - USING com.atomikos.icatch.max_timeout = 300000
94 [main] INFO atomikos - USING com.atomikos.icatch.tm_unique_name = PaymentsTransactions
94 [main] INFO atomikos - USING java.naming.factory.initial = com.sun.jndi.rmi.registry.RegistryContextFactory
94 [main] INFO atomikos - USING java.naming.provider.url = rmi://localhost:1099
94 [main] INFO atomikos - USING com.atomikos.icatch.service = com.atomikos.icatch.standalone.UserTransactionServiceFactory
94 [main] INFO atomikos - USING com.atomikos.icatch.force_shutdown_on_vm_exit = false
94 [main] INFO atomikos - USING com.atomikos.icatch.default_jta_timeout = 10000
INFO - JtaTransactionManager.checkUserTransactionAndTransactionManager(469) | Using JTA UserTransaction: com.atomikos.icatch.jta.UserTransactionImp@16a6027
INFO - JtaTransactionManager.checkUserTransactionAndTransactionManager(480) | Using JTA TransactionManager: com.atomikos.icatch.jta.UserTransactionManager@e68513
DEBUG - NameMatchTransactionAttributeSource.addTransactionalMethod(94) | Adding transactional method [*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
DEBUG - AbstractPlatformTransactionManager.getTransaction(365) | Creating new transaction with name [com.evolvus.payments.manager.IPaymentsManager.findColumnChartDisplayByGateWays]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
40500 [http-8080-Processor24] WARN atomikos - Attempt to create a transaction with a timeout that exceeds com.atomikos.icatch.max_timeout - truncating to: 300000
40641 [http-8080-Processor24] INFO atomikos - THREADS: using JDK thread pooling...
40703 [http-8080-Processor24] INFO atomikos - createCompositeTransaction ( 3000000 ): created new ROOT transaction with id PaymentsTransactions0000100688
DEBUG - AbstractPlatformTransactionManager.handleExistingTransaction(470) | Participating in existing transaction
DEBUG - AbstractPlatformTransactionManager.handleExistingTransaction(470) | Participating in existing transaction
DEBUG - AbstractPlatformTransactionManager.processRollback(850) | Participating transaction failed - marking existing transaction as rollback-only
DEBUG - JtaTransactionManager.doSetRollbackOnly(1060) | Setting JTA transaction rollback-only
49110 [http-8080-Processor24] INFO atomikos - setRollbackOnly() called for transaction PaymentsTransactions0000100688
DEBUG - AbstractPlatformTransactionManager.processRollback(843) | Initiating transaction rollback
49172 [http-8080-Processor24] INFO atomikos - afterCompletion ( STATUS_ROLLEDBACK ) called on Synchronization: org.hibernate.transaction.CacheSynchronization
49172 [http-8080-Processor24] INFO atomikos - afterCompletion ( STATUS_ROLLEDBACK ) called on Synchronization: org.hibernate.ejb.EntityManagerImpl$1@1f6e48a
49172 [http-8080-Processor24] INFO atomikos - rollback() done of transaction PaymentsTransactions0000100688
could you help me ?
Clearly your database insert is not happening within the scope of your transaction manager's current transaction.
A few ideas:
1) Maybe its just not in your posting, but I don't see the Spring @Transactional annotation on your service class. What is your strategy for controlling transaction boundaries?
2) Because you are using JNDI, we don't get to see your data source, but if you are using Atomikos, you should be using their XA aware pooling data source. Are you?
3) You should increase Atomikos normal logging to DEBUG to see exactly which SQL commands it is handling.
4) Atomikos keeps transaction logs that are outside your normal log files. These are used for recover and other purposes. You should also check these for clues.
Hope this helps.
Update:
MySQL has some limitations with XA transactions as you can here about here. Try this configuration out within your context.xml and at least see if it works. It uses an XA aware (but not XA capable) data source from Atomikos. If this works then you can go from there:
<Transaction factory="com.atomikos.icatch.jta.UserTransactionFactory" />
and the define the JNDI data source for injection into your entity manager:
<Resource name="jdbc/myDataSource" auth="Container"
factory="org.apache.naming.factory.BeanFactory"
type="com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean"
uniqueResourceName="myMySqlDatabase" driverClassName="com.mysql.jdbc.Driver" url="......" user="....." password="...." maxPoolSize="20" reapTimeout="300" />
这篇关于事务回滚,但插入一条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!