1

我收到异常是 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)
4

1 回答 1

1

这种异常表示请求无法执行,因为该操作不是受支持的功能。例如,因为不支持嵌套事务,所以当已经与事务关联的调用线程尝试启动新事务时,事务管理器会抛出此异常。当线程已经与一个事务关联并尝试启动第二个事务时,就会发生嵌套事务。

于 2012-12-17T14:13:33.393 回答