You are viewing a plain text version of this content. The canonical link for it is here.
Posted to graffito-dev@incubator.apache.org by Martin Koci <ma...@aura.cz> on 2005/10/31 14:58:31 UTC

[jcr-mapping] Session lifecycle

Hi,
I have question about javax.jcr.Session management with jcr-mapping.
Instance of PM encapsulates a session. But this session can be 
invalidated with session.logout(). Than session.isLive() returns false - 
also returns false if session times-out or is disconnected from 
repository for some reason.

So such behavior may lead to :
Caused by: javax.jcr.RepositoryException: this session has been closed
at org.apache.jackrabbit.core.SessionImpl.sanityCheck(SessionImpl.java:329)
at org.apache.jackrabbit.core.SessionImpl.itemExists(SessionImpl.java:743)
at 
org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerImpl.objectExists(PersistenceManagerImpl.java:242)

David Nuescheler recommends create new session on every request! See 
http://www.mail-archive.com/jackrabbit-dev@incubator.apache.org/msg02273.html

Because repository can disconnect session we cannot rely on instance in 
PM. There can be some re-new or re-connect logic.

-- 
Mgr. Martin Kočí
---------------------------------
AURA, s.r.o.
Úvoz 499/56; 602 00 Brno
ISO 9001 certifikovaná společnost
tel./fax: +420 5 43 24 51 11
e-mail:  martin.koci@aura.cz
internet: http://www.aura.cz
         http://www.j2ee.cz
--------------------------------- 


Re: [jcr-mapping] Session lifecycle

Posted by Martin Koci <ma...@aura.cz>.
No, its not actually needed (now), because Jackrabbit invalidates 
Session only in method Session.logout() (as I found in its sources). But 
it can be problem in future because JCR spec says: "Session can expire 
or be disconnected from repository for some reason". Maybe (I dont know) 
Day JCR implementation has expiring feature so client can try to use 
instance of PM with expired and invalid session.


Christophe Lombart wrote:
> On 10/31/05, Martin Koci <ma...@aura.cz> wrote:
>   
>> David Nuescheler recommends create new session on every request! See
>> http://www.mail-archive.com/jackrabbit-dev@incubator.apache.org/msg02273.html
>>
>>     
>
> If you mean one new session (=> one new persistence manager) per HTTP
> request. I think it is not a problem to do it now.
> Honestly, we are not yet working on servlet integration and also not
> on tx management. So, maybe I miss something - Can you explain more ?
>
>
> Thanks,
> Christophe
>
>
>   


-- 
Mgr. Martin Kočí
---------------------------------
AURA, s.r.o.
Úvoz 499/56; 602 00 Brno
ISO 9001 certifikovaná společnost
tel./fax: +420 5 43 24 51 11
e-mail:  martin.koci@aura.cz
internet: http://www.aura.cz
         http://www.j2ee.cz
--------------------------------- 


Re: [jcr-mapping] Session lifecycle

Posted by Christophe Lombart <ch...@gmail.com>.
On 10/31/05, Martin Koci <ma...@aura.cz> wrote:
>
> David Nuescheler recommends create new session on every request! See
> http://www.mail-archive.com/jackrabbit-dev@incubator.apache.org/msg02273.html
>

If you mean one new session (=> one new persistence manager) per HTTP
request. I think it is not a problem to do it now.
Honestly, we are not yet working on servlet integration and also not
on tx management. So, maybe I miss something - Can you explain more ?


Thanks,
Christophe