Uploaded image for project: 'Seam 2'
  1. Seam 2
  2. JBSEAM-4395

Endless loop when an exception occurs during commit inside a long running conversation, and there is an <exception> clause to handle it in page.xml

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.2.0.GA, 2.2.1.CR1
    • Fix Version/s: None
    • Component/s: Exception Handling
    • Labels:
      None
    • Environment:

      WebSphere v7.0.0.5, Seam 2.2.1-SNAPSHOT

    • Workaround:
      Workaround Exists
    • Workaround Description:
      Hide

      "Dirty" workaround:
      Add an observer to end the conversation when an exception is trapped:
      @Name("observers")
      @AutoCreate
      public class Observers {
      @Observer("org.jboss.seam.exceptionHandled")
      public void exceptionHandled()

      { // add some logic here to end the conversation only when a persistence exception is observed Manager.instance().endConversation(true); }

      }

      Show
      "Dirty" workaround: Add an observer to end the conversation when an exception is trapped: @Name("observers") @AutoCreate public class Observers { @Observer("org.jboss.seam.exceptionHandled") public void exceptionHandled() { // add some logic here to end the conversation only when a persistence exception is observed Manager.instance().endConversation(true); } }

      Description

      Scenario:

      • process is in a long running conversation
      • a persistence exception occurs (e.g. OptimisticLockingException), during either a call to flush() or during the automatic commit() of the transaction
      • a clause <exception> is declared in pages.xml to handle the exception and redirect to a generic error page (e.g. <exception> that will handle all exceptions..) like this:
        <exception>
        <end-conversation/>
        <redirect view-id="/erreur_exception.xhtml" />
        </exception>

      During the commit, the exception occurs, Seam catch it and pass it to the exception handler.
      The exception handler sees that the user has to be redirected to the error page.
      The long running conversation is still active, handling the "dirty" objects that cause the persistence failure

      The request to process the error page starts. During the "RESTORE_VIEW", the dirty object that are in the conversation are then flushed again to the database, causing again the persistence exception, triggering the seam exception handling mechanism, that will redirect to the error handling page, causing an endless loop

      A workaround to this is to add an observer on "org.jboss.seam.exceptionHandled" that will kill the current conversation and so remove the dirty objects from the session and the error page is display (see the forum reference)

      Some thoughts:

      • the documentation gives an example on how to handle OptimisticLockingException, but in our case, the way it is, this causes an infinite loop
      • is the <end-conversation/> clause working correctly? At what time during exception handling is the end-conversation supposed to occur?

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  titou09 titou10 titou10
                • Votes:
                  1 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated: