My current flow looks much like this, except I placed a cocoon.log.error() call in the catch(return) and I can't see anything logged, I also tried to place a breakpoint in the flowscript debugger and the code was skipped. I'm afraid the session is simply never closed, which is of course another solution (there will only be some hibernate warnings when the unclosed sessions get garbage collected).
My understanding of http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations is that catch(return) will only be interpreted when a continuation object has been captured so it is useless with sendPage(). (or was this changed in 2.1.5 ?) Regards, Nicolas. PS: I posted a sample flowscript along with console output somewhere up this thread. -----Original Message----- From: Upayavira [mailto:[EMAIL PROTECTED] Sent: 10 juin, 2004 15:14 To: [EMAIL PROTECTED] Subject: Re: Flow + Hibernate and lazy initialization Nicolas Bielza wrote: >Thanks, but I can't think of any more testing to do.. > >I wanted to use sendPage() since there really is no need for >continuation in my flow.. > >If I use sendPageAndWait() and log something in the catch(return), I >can see that the lasy initialization is executed after that (and if I >close the session in the catch(return), I can see that the lazy >initialization fails). > >Maybe "someone"'s code did not use lazy collections ? > > He assures me he does. >The fix I'm using now is to fetch lazy collections elements in my >query. > Here's a cut down sample of some of his working code: function scenario () { var factory = cocoon.getComponent (PersistanceFactory.ROLE); var session = factory.createSession (); try { var scenario = MyObj.load (session, new java.lang.Long (something), null); cocoon.sendPage (cocoon.parameters["screen"], { scenario: scenario }); catch (return) { session.close(); } // the page has finished rendering } catch (e) { cocoon.log.error (e); cocoon.sendPage("screen/error", {message: "scenarios.scenario.notavailable"}); session.close(); } finally { cocoon.releaseComponent(factory); } } How does yours match? Could you post it? Regards, Upayavira >-----Original Message----- >From: Upayavira [mailto:[EMAIL PROTECTED] >Sent: 10 juin, 2004 14:50 >To: [EMAIL PROTECTED] >Subject: Re: Flow + Hibernate and lazy initialization > > >Nicolas Bielza wrote: > > > >>Thanks, I tried this and the catch(return) is not interpreted when >>using sendPage(), it's just ignored. >> >>I also tried your previous suggestion, but my app was not responding >>anymore, maybe the "FOM_Cocoon.suicide();" line is required ? >> >>Anyway, this probably won't help much, since I also tried the >>postpipeline code with sendPageAndWait() and it's also interpreted >>before the view is rendered. This looks like a bug : The >>http://cocoon.apache.org/2.1/userdocs/flow/api.html#sendPageAndWait >>page says : >> >>"If provided, the postPipelineCode function will be executed after >>pipeline processing is complete but before the script is suspended. You >> >> > > > >>can use this to release resources that are needed during the pipeline >>processing but should not become part of the continuation" >> >>If the "catch(return)" code is interpreted just before the script is >>suspended, then it looks like the script is suspended BEFORE the >>pipeline processing is complete ! So the postpipeline code is really a >>postpipelineinvocation code. >> >>It looks like the only solution that would work is to use a filter >>servlet but I don't have such things in my environment :( >> >> >> >> >I'd say persevere with the catch(return) idea. The reason I proposed it >is because I asked someone who had exactly that problem with Hibernate, >and it works for him. And he was advised by the person who coded a lot >of the flow stuff. > >Regards, Upayavira > > > >>Regards, >> >>Nicolas. >> >>-----Original Message----- >>From: Upayavira [mailto:[EMAIL PROTECTED] >>Sent: 10 juin, 2004 14:14 >>To: [EMAIL PROTECTED] >>Subject: Re: Flow + Hibernate and lazy initialization >> >> >>Nicolas Bielza wrote: >> >> >> >> >> >>>Well, when I say that they "work", I mean that they are interpreted >>>and >>> >>> >>> >>> >> >> >> >> >>>not ignored. I'm not sure that they actually "work", since they don't >>>seem to wait for the view to be rendered. (but maybe this is by >>>design..) >>> >>> >>> >>> >>> >>Try this: >> >>function someFunction() { >> >> var session = ... >> ... >> >> cocoon.sendPage(...); >> >> catch (return) { >> // after calling the view layer but before control >> // leaves the interpreter >> } >>} >> >>Note, the catch is not associated with a try. >> >>This came of the previously referenced >>http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations >>but that page is pretty frightening. >> >>Hope this helps. >> >>Regards, Upayavira >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
