Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Transactions

  1. #1
    Join Date
    Apr 2005
    Location
    Edinburgh
    Posts
    18

    Default Transactions

    I have followed the item list example for setting up and checking for a valid transaction, but have noticed some strange behaviour. When I check for a valid transaction in the action state that a form submits to, result is true. If I make the check in a subsequent action state which is reached through the success transition of said action, it is false.

    Any ideas on how to solve this?

    Thanks
    Daniel

  2. #2
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    How are you doing the "check"? Make sure you are passing "false" to the end parameter of the assertInTransaction or isInTransaction methods.

    Erwin

  3. #3
    Join Date
    Apr 2005
    Location
    Edinburgh
    Posts
    18

    Default

    I am passing in false to the isInTransaction method

  4. #4
    Join Date
    Apr 2005
    Location
    Edinburgh
    Posts
    18

    Default

    I begin the transaction with
    Code:
    context.getTransactionSynchronizer().beginTransaction();
    And check in a subsequent action state using
    Code:
    if(!context.getTransactionSynchronizer().inTransaction(false)){
      //do error stuff
    }
    If this action state is after a form submission, which submits the token, its all good. If the action state follows on from another action state ie
    Code:
    <action-state id="validateApplication">
    		<action bean="applicationWorkflowAction" method="validateApplication"/>
    		<transition on="success" to="submitApplication"/>
                    <transition on="error" to="applicationForm"/>
    	</action-state>
    Where validateApplication is reached from a form submission and the transaction check returns true, in submitApplication however the transaction check returns false.

  5. #5
    Join Date
    Apr 2005
    Location
    Edinburgh
    Posts
    18

    Default

    Following this through the debugger it looks as though in the second state, the Event returned by context.getLastEvent() has no parameters, which obviously means no transaction token. The same is true when getLastEvent() is called in the inTransaction() method of InternalRequestContext.

    Is this the expected behaviour?

  6. #6
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    No it is not. This is a bug. The system should always try to find the transaction token in the originating event of the request context to verify that the client is "in" the transaction.

    I've fixed the bug and the new code is in CVS. This will ofcourse also be included in the Preview 3 release.

    Erwin

  7. #7
    Join Date
    Apr 2005
    Location
    Edinburgh
    Posts
    18

    Default

    Excellent, thanks for the response and the fix

  8. #8
    Join Date
    Apr 2005
    Location
    Edinburgh
    Posts
    18

    Default

    Prior to this fix, I was able to press the back button and submit a form again to test that the transaction code was working, but now when doing this a NoSuchFlowExecutionException is thrown. Is this correct? Also what is the recommended way of dealing with such exceptions?

  9. #9
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Daniel,

    Has your flow ended (reached an end state) when you attempt to do this? If so, that explains the NoSuchFlowExecutionException. You could always catch that and reroute the user to a error page that allows them to restart a new flow if they'd like to.

    Keith
    Keith Donald
    Core Spring Development Team

  10. #10
    Join Date
    Apr 2005
    Location
    Edinburgh
    Posts
    18

    Default

    The flow has ended at this point.

    Does webflow provide any mechanism to catch exceptions such as this? My solution at the moment is to declare it as a global exception in my struts config which obviously isn't ideal as there can only be one place it can go to, rather than a 'handler' per flow.

Similar Threads

  1. HibernateTemplate and transactions
    By Simon Brunning in forum Data
    Replies: 4
    Last Post: Mar 9th, 2009, 12:37 AM
  2. Client Defined Transactions
    By haninaguib in forum Data
    Replies: 4
    Last Post: Oct 24th, 2005, 01:18 PM
  3. JDO Transactions and JUnit testing
    By markds75 in forum Data
    Replies: 2
    Last Post: Sep 17th, 2005, 01:46 AM
  4. Replies: 1
    Last Post: Mar 23rd, 2005, 05:32 AM
  5. Replies: 4
    Last Post: Mar 15th, 2005, 05:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •