我得到的异常是javax.transaction.NotSupportedException
当我将UserTransaction加入entityManager时,我正在使用与jpa的jta事务我将得到此异常
SampleCode:
@Begin(join=true)
public String tempCustomerMigration(List<DoTempCustomers> list) {
try {
UserTransaction userTx = (UserTransaction) org.jboss.seam.Component.getInstance("org.jboss.seam.transaction.transaction");
userTx.setTransactionTimeout(10 * 60);
userTx.begin();
for(DoTempCustomers tempCustomers:list){
TempCustomers temp=new TempCustomers();
BeanUtils.copyProperties(temp, tempCustomers);
entityManager.joinTransaction();
getEntityManager().persist(temp);
getEntityManager().flush();
userTx.commit();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "save";
}
日志:
2012-12-17 16:08:24,834 ERROR [STDERR] javax.transaction.NotSupportedException
2012-12-17 16:08:24,836 ERROR [STDERR] at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.begin(BaseTransaction.java:79)
2012-12-17 16:08:24,836 ERROR [STDERR] at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.begin(BaseTransactionManagerDelegate.java:77)
2012-12-17 16:08:24,836 ERROR [STDERR] at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.begin(ServerVMClientUserTransaction.java:124)
2012-12-17 16:08:24,836 ERROR [STDERR] at org.jboss.seam.transaction.UTTransaction.begin(UTTransaction.java:39)
2012-12-17 16:08:24,836 ERROR [STDERR] at com.manam.mobee.migrationCustomerManagement.MigrationCustomerHome.tempCustomerMigration(MigrationCustomerHome.java:253)
2012-12-17 16:08:24,836 ERROR [STDERR] at com.manam.mobee.migrationCustomerManagement.MigrationCustomerHome.migrateCustomers(MigrationCustomerHome.java:234)
2012-12-17 16:08:24,836 ERROR [STDERR] at com.manam.mobee.migrationCustomerManagement.MigrationCustomerHome.migrateData(MigrationCustomerHome.java:153)
2012-12-17 16:08:24,836 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2012-12-17 16:08:24,836 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2012-12-17 16:08:24,836 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2012-12-17 16:08:24,836 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
2012-12-17 16:08:24,836 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
2012-12-17 16:08:24,836 ERROR [STDERR] at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
2012-12-17 16:08:24,836 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
2012-12-17 16:08:24,837 ERROR [STDERR] at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
答案 0 :(得分:1)
这种异常表示无法执行请求,因为该操作不是受支持的功能。 例如,由于不支持嵌套事务,因此当已与事务关联的调用线程尝试启动新事务时,事务管理器将抛出此异常。 当线程已与一个事务关联并尝试启动第二个事务时,就会发生嵌套事务。