0 Replies Latest reply on Mar 23, 2006 8:13 PM by Ryan Pape

    Handling Wizard-Style submission failure

    Ryan Pape Newbie

      I am using an Extended Persistence context, SeamManagedPhaseListener, etc. to collect information through a number of wizard-like steps.

      When the user confirms, I perform all of my persistence. In the event of some unforseen database error, I want to rollback the transaction, present the user with an error message and allow them to potentially resolve the error and resubmit.

      To do this, I catch all exceptions around the persistence logic and issue a

      SessionContext.setRollbackOnly();

      Something like

      try
      {
       em.persist(x);
      } catch (RuntimeEception e)
      {
       ctx.setRollbackOnly();
      
       //set error message
      
       return "errorpage";
      }
      



      then set an error message and return the page that will display it.

      The setRollbackOnly() completes without error, however after returning the page to navigate to I get the following:

      Caused by: javax.transaction.NotSupportedException: Transaction already active, cannot nest transactions.
       at org.jboss.tm.TxManager.begin(TxManager.java:208)
      


      What is the proper way to attempt to recover from persistence errors?