2 Replies Latest reply on Jan 20, 2012 11:41 AM by Immo Benjes

    Starting new Transaction after rollback

    Immo Benjes Newbie


      I am using Seam 2.2 POJO's and Seam managed transactions runing on JBoss 5.1

      from components.xml:

      <persistence:managed-persistence-context auto-create="true"
        name="entityManager" persistence-unit-jndi-name="@puJndiName@"/>

      My problem is that I sometimes have to write stuff to the database after an exception triggered a rollback. Is there any way to 'restart' a transaction of create a new one?
      I've tried calling async methods which are annotated like this:

      public void writeErrorStatus(...){
      // update the DB with the error status

      And I use it like this:

      RollbackHandler handler = Component.getInstance("rollbackHandler");

      This seems to work most of the time but now I came across a case where I still
      get javax.persistence.TransactionRequiredException: no transaction is in progress

      How can I really make sure that I have a transaction to write to the DB even after a rollback?

      As far as I know the 'REQUIRES_NEW' is not supported for Seam POJOs. So what could I do instead?