2 Replies Latest reply on Apr 10, 2008 11:41 AM by Pete Muir

    StaleObjectStateException, pages.xml and natural conversations



      I'm following the example in the Seam docs for handling the hibernate equivalent of the OptimisticLockException:

      <exception class="org.hibernate.StaleObjectStateException">
         <redirect view-id="/error.xhtml">
            <message>Another user changed the same data, please try again</message>

      The conversation I'm trying to end with <end-conversation/> is a natural conversation. After provoking a StaleObjectStateException by editing the same data within the natural conversation, I get redirected to error.xhtml. So far so good.

      However, when I check the debug page I can still see the natural conversation I just ended listed there. What's even stranger is when I execute this code:

      ConversationEntry entry = ConversationEntries.instance()
                          "NaturalConversation:" + conversationObject.getId());

      After this, entry is null. Given that it was listed in the debug page I was expecting it to have a value.

      If I try to start a new natural conversation with the same id (conversationObject.getId), I get redirected to the debug page and the natural conversation that was listed there previously is now ended (!). When I go back and try to start the natural conversation again, it starts as normal.

      I start natural conversations in pages.xml like this:

           conversation="NaturalConversation" flush-mode="manual" />

      Any ideas about what is causing this strange behaviour?