我收到异常是 javax.transaction.NotSupportedException
当我将 UserTransaction 加入 entityManager 时,我正在将 jta 事务与 jpa 一起使用,我将收到此异常
示例代码:
@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)