Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transaction TransactionImple ActionStatus.ABORTED was already rolled back

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

I have this entity :

@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;

With this Interface :

@Local
public interface PlagePersistenceManager {

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

}

And the implementation :

@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");

    }
}

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

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.

The method deleteAllPlages contains :

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

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();

Thxs.

like image 419
Kikou Avatar asked Mar 21 '16 16:03

Kikou


1 Answers

I've noticed that you're using org.jboss.annotation.ejb.TransactionTimeout instead of the required EJB3 one: org.jboss.ejb3.annotation.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).

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

like image 54
António Ribeiro Avatar answered Sep 30 '22 11:09

António Ribeiro