Announcement Announcement Module
No announcement yet.
LazyInitializationException and webflow Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Yes. You're absolutely right. Good catch. WebFlow simply calls requestProcessed() then returns the ViewDescriptor to the FlowController. By the time the ViewDescriptor is translated to a view and rendered, the Hibernate Session has been closed. Looks like I'm not doing any lazy loading in my views.

    Looks like we want to defer closure of the Hibernate session until after the FlowController has finished processing the view. I'm not sure how that will work, off hand, but I'll look into it. Feel free to weigh in with any ideas.



    • #17
      The problem is that to put session in flowScope, it has to be serialized. And a Session instance can't be serialized if it is connected

      without OSIV :
      • disconnect the session before put it in FlowScope cause it not to be connected in the view
      • let the session connected before put it in FlowScope crash because of the Serialization

      with OSIV :
      • disconnect the session before put it in FlowScope cause a NPE in OSIV (in Interceptor or Filter)
      • let the session connected before put it in FlowScope crash because of the Serialization

      And what about put the session (hibernate) in HttpSession inspite of in FlowScope ?


      • #18
        Thieumdesp, are you by any chance using continuations (i.e. HttpSessionContinuationFlowExecutionStorage) with the flows in which you are getting LazyInit exceptions?

        I am testing with the OpenSessionInFlowListener also, and get the same behavior you describe. If I comment out disconnectSession (in requestProcessed), I get the 'Cannot serialize a session while connected' message.

        However, if I change to using HttpSessionFlowExecutionStorage, and leave the disconnectSession commented out, it does not attempt to serialize the connection, and the view renders.

        Not necessarily a solution since I want continuations, but more info. Could we possible disconnect and serialize the session using the triggerAfterCompletion from the DispatcherServlet, which is called after the view is rendered?


        • #19
          I managed to get something working based on my triggerAfterCompletion idea from the last post. It still does not work with continuations, because the flow state is always stored (serialized) prior to the view being rendered (the storage is done in the FlowController that then returns the ViewDescriptor, which is rendered).

          If anyone is interested in trying this with HttpSessionFlowExecutionStorage, it seems to work; here are the changes I made to the code posted previously for OpenSessionInFlowListener. It now implements HandlerInterceptor, and I moved the requestProcessed logic to the afterCompletion interceptor call. (I'm new to posting code, so let me know if there is a better way to do it)

          In addition to defining this as a flow listener for the FlowExecutionmanager, you also have to declare it as a HandlerInterceptor. For me, this was done by adding the following to my SimpleUrlHandlerMapping bean definition:

          <property name="interceptors" ref="openSessionInFlowListener" />


          • #20

            where can i find the OpenSessionInFlowListener ? I'm using the Spring-WebFlow 1.0ea.



            • #21


              • #22

                thank you for your answer. I've got many compile errors. It seems that webflow has changed in many parts (for example: Scope). Where can i find a newer one?


                • #23
                  Indeed. I hadn't tried it, and couldn't say whether anyone has upgraded OSIF. Looks like significant refactorings beyond just renaming Scope->ScopeType. Don't know what the current wisdom is on the best thing to do here. If I don't hear differently I might end up updated OSIF for compatibility with CVS SWF, but we'll see...


                  • #24


                    • #25
                      Yep, saw that last night...


                      • #26
                        I did manage to adapt the older implementation I had working to webflow 1.0ea. The hardest part to deal with was the integration with continuations, and avoiding serializing the entire hibernate session. I think I'll post comments at the JIRA link provided above

                        I posted some code to the JIRA issue referenced above, the OSIF I'm using with swf 1.0ea. I'd be interested in what others are doing/thoughts on the approach.
                        Last edited by ande; Mar 24th, 2006, 09:05 PM.


                        • #27
                          Any update on this? I'm having the same lazy load problems using webflow...



                          • #28

                            Building upon Ande's work, instead of putting the session in "flow scope" with continuations enabled -- which results in a serialized execution state snapshot that can later be restored -- you could use "conversation scope", which by default is not serialized and is simply stored in the HTTP session.