事务TransactionImple ActionStatus.ABORTED已回滚 [英] Transaction TransactionImple ActionStatus.ABORTED was already rolled back

查看:303
本文介绍了事务TransactionImple ActionStatus.ABORTED已回滚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现了DTO业务从TomEE到JBoss的迁移.

I realize a migration of a DTO Business from TomEE to JBoss .

我有这个实体:

@NamedQueries({
@NamedQuery(name = "common.plagebusiness.plage.getAllPlages", query = "SELECT p FROM Plage p ORDER BY p.plageRgMax, p.plageCReseau") })
@Entity
@Table(name = "PLAGE")
public class Plage {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "idPlage")
    private Integer idPlage;

    @Column(name = "rgMin")
    private String plageRgMin;

使用此界面:

@Local
public interface PlagePersistenceManager {

public void importPlages(List<DetailFH55> listeEnregDetail) throws PlageBusinessException, ParseException;

}

执行:

@Stateless(name = "common.plagebusiness.PlagePersistenceManager")
public class PlagePersistenceManagerImpl implements PlagePersistenceManager {

    private static final Logger LOGGER = Logger.getLogger(PlagePersistenceManager.class);

    @PersistenceContext(unitName = "PlageBusiness")
    private EntityManager em;

    @Override
    public void importPlages(final List<DetailFH55> listeEnregDetail) throws PlageBusinessException, ParseException {
        LOGGER.debug("Entree dans importPlages");

        if (null != listeEnregDetail) {
            LOGGER.info("Debut Delete");

            // suppression des plages
            this.deleteAllPlages();

            LOGGER.info("Fin Delete et Debut Insertion en bdd");

            for (final DetailFH55 myEnreg : listeEnregDetail) {
                // insertion des nouvelles plages
                final Plage plage = this.convertEnregDetailToPersist(myEnreg);
                this.em.persist(plage);
            }

            LOGGER.info("Fin Insertion en bdd");
        }

        LOGGER.debug("Sortie dans importPlages");

    }
}

不幸的是,em.persist不起作用,我有这个例外:

Unfortunately, the em.persist doesn't work , i had this exeption:

Caused by: javax.transaction.RollbackException: JBAS014585: Transaction 'TransactionImple < ac, BasicAction: 0:ffff0a48268b:4bc8a0e:56f01b76:18 status: ActionStatus.ABORTED >' was already rolled back

我在论坛上读到这是因为Jboss的超时.我不想更改Jboss的配置,所以我尝试通过输入

I read in forums that it was because of the timeOut of Jboss. I don't want to change the configuration of Jboss, so I tried by putting ,

@org.jboss.annotation.ejb.TransactionTimeout(10000000) 
public void importPlages(final List<DetailFH55> listeEnregDetail) throws PlageBusinessException, ParseException  

仍然是相同的异常...此代码出了什么问题.

Still the same exception...what's wrong with this code.

deleteAllPlages方法包含:

The method deleteAllPlages contains :

@Override
public int deleteAllPlages() throws PlageBusinessException {
    final Query query = this.em.createNativeQuery("DELETE FROM `PLAGE`");
    return query.executeUpdate();
}

我试图在persist(plage)之后加上flush()和clear(),并且仍然是相同的Exception.

I tried to put a flush() and clear() after the persist(plage), and still same Exception.

final Plage plage = this.convertEnregDetailToPersist(myEnreg);
                this.em.persist(plage);
                this.em.flush();
                this.em.clear();

感谢.

推荐答案

我注意到您使用的是org.jboss.annotation.ejb.TransactionTimeout而不是

I've noticed that you're using org.jboss.annotation.ejb.TransactionTimeout instead of the required EJB3 one: org.jboss.ejb3.annotation.TransactionTimeout.

在您的POM中,尝试用这个替换引用您当前TransactionTimeout的依赖项:

In your POM, try replacing the dependency that refers your current TransactionTimeout by this one:

<dependency>
    <groupId>org.jboss.ejb3</groupId>
    <artifactId>jboss-ejb3-ext-api</artifactId>
    <version>2.2.0.Final</version>
    <scope>provided</scope>
</dependency>

然后您可以指定您的值和单位:

Then you can specify your value and unit:

@TransactionTimeout(value = 10, unit = TimeUnit.SECONDS).

您可以在JBoss的论坛上找到相关问题.

You can find a related issue at JBoss's forum.

这篇关于事务TransactionImple ActionStatus.ABORTED已回滚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆