I tried to use the catch(return) trick but it doesn't seem to work. (I'm
using cocoon 2.1.4)
I added some log messages in the flowscript and it seems that the
catch(return) is not executed when I call sendPage() (the script
debugger also exposed this, and after a while, I started to see some
warnings about unclosed sessions...).
I tried with sendPageAndWait() and this time the catch(return) got
executed, but it was called before the pipeline completed: I still had
lazy initialization exceptions during pipeline processing.
I also tried to close the session in the postpipeline code (when using
sendPageAndWait()) and again, the session was closed before pipeline
completed.
Here's an example flowscript (I'm not closing the session here, just
logging) :
try {
// ...
var list = query.list();
cocoon.log.error("I'm about to call cocoon.sendPageAndWait()");
cocoon.sendPageAndWait("report.vm", {"list" : new HashSet(list)},
function() { cocoon.log.error("I'm in postpipeline code"); }, 0);
catch(return) {
cocoon.log.error("I'm inside catch(return)");
}
}
finally {
cocoon.log.error("I'm inside finally block");
//clean up
cocoon.releaseComponent(hibernateFactory);
}
Now, here's the console output:
Hibernate: select introspecd0_.id as id, introspecd0_.envelop as
envelop, introspecd0_.reference as reference,
introspecd0_.tradingPartner as tradingP4_, introspecd0_.docType as
docType from Introspec_Document introspecd0_ inner join
Introspec_History statushist1_ on introspecd0_.id=statushist1_.docId
Hibernate: select introspecd0_.id as id0_, introspecd0_.name as name0_
from Introspec_DocType introspecd0_ where introspecd0_.id=?
ERROR 2004-06-10 12:14:29.561 [flow ] (): I'm about to call
cocoon.sendPageAndWait()
ERROR 2004-06-10 12:14:29.632 [flow ] (): I'm in postpipeline code
ERROR 2004-06-10 12:14:29.632 [flow ] (): I'm inside catch(return)
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc
Hibernate: select introspecs0_.id as id0_, introspecs0_.code as code0_
from Introspec_Status introspecs0_ where introspecs0_.id=?
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc
You can clearly see the hibernate request being executed after passing
through both postpipeline and catch(return) blocks.
Looking back at
http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations, it seems
obvious that catch(return) is only used with continuation objects so
it's ignored when calling sendPage().
But I think this is quite ambiguous:
>If you want to execute Flowscript code after calling the view layer but
before control
>leaves the interpreter, catch(return) will help
If "after calling the view layer" means "just after calling the view
layer, but before it's completed", I can't see any use for this feature.
So far, it looks like there's no way to know when the view pipeline is
completed, maybe this is to avoid problems if the view "re-entered" the
flow (just guessing) ?
Finally, I'd like to know if anyone can confirm what I'm reporting (I'm
running in a minimal cocoon environment and it's not impossible that I
removed some needed components...) ?
Thanks,
Nicolas.
-----Original Message-----
From: Leszek Gawron [mailto:[EMAIL PROTECTED]
Sent: 10 juin, 2004 05:37
To: [EMAIL PROTECTED]
Subject: Re: Flow + Hibernate and lazy initialization
Leszek Gawron wrote:
>> Well, I cannot see why the releasing cannot be done in the Javascript
>> statement following the sendPage... assuming the behaviour you
>> observed was not just a bug in the Flowscript component, of course.
>
> If this is as you say you should raise this problem at cocoon-dev. I
> also wanted to loose Open Session In View pattern in favor of some
> hibernate avalon component, but that looks impossible now.
See this[1], and this[2] and this[3] and this[4]
[1] http://marc.theaimsgroup.com/?t=108681937800001&r=1&w=2&n=2
[2] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825181219265&w=2
[3] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825410721036&w=2
[4] http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations
LG
---------------------------------------------------------------------
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]