jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jason wang <jasonqiw...@hotmail.com>
Subject RE: session.logout throws Exception : Inactive logical session handle called
Date Fri, 13 Aug 2010 05:34:24 GMT

Hi,Thank you very much for your reply.
So when the session handle is closed, the underlying connection is NOT closed, because the
actual session is returned to the pool, is that right? But what would be the correct way to
manage JackRabbit session in a stateless session bean? For example,
If I set  bindSessionToTransaction-flag to false, then when should I call session.logout()
in order to release resource?
If I set  bindSessionToTransaction-flag to true, and a session is closed when the transaction
commit, does that mean I don't need to invoke the session.logout method? No memory leak?

Another approach is to call session login, and session logout in every method of the bean?
but  I doubt this is a good design.   
Thanks a lot for your help.Jason 

> Date: Thu, 12 Aug 2010 13:02:14 +0200
> From: dokla@mail.upb.de
> To: users@jackrabbit.apache.org
> Subject: Re: session.logout throws Exception : Inactive logical session handle called
> Hi,
> I think you must pay attention to the fact, that your are connecting to 
> Jackrabbit via the JCA package. This package realizes a JCA adapter, in 
> conjunction with this adapter the application server is able to keep a 
> pool of JCR sessions. This pool keeps the actual JCR sessions. What you 
> are dealing with in your session beans are not the actual JCR sessions, 
> but session handles, proxies so to speak, provided by the JCA package. 
> Due to the bindSessionToTransaction-flag these JCA session handles are 
> closed whenever a container managed or bean managed transaction commits. 
> However, the actual JCR sessions associated with these session handles 
> are not closed, but kept alive in a pool.
> So your error probably occurs, because the JCA session handle is already 
> closed (due to a transaction commit) when you call the session.isLive() 
> oder session.logout() in  the @PreDestroy method.
> At least this is how I understand it... :)
> Am 12.08.2010 10:36, schrieb jason wang:
> > Hi,Can someone help me with the following problem.I have a stateless session bean
which has the following methods:	@PostConstruct	private void initialize(){		try {			session
= repository.login(new SimpleCredentials("username", "password".toCharArray()));		}catch (LoginException
e) {		}catch(RepositoryException e){		}	}		@PreDestroy	private void cleanup(){		if (session!=null&&
 session.isLive()){			session.logout();			session=null;		}	}		public void addCategory(String
absPath, JRCategory jrCategory){
> >      	
> >      	try {
> >      		Node parentNode = session.getNode(absPath);
> >      		Node categoryNode = parentNode.addNode(jrCategory.getCategoryName(), "nt:unstructured");
> >      		session.save();
> >      	}
> > 		}catch( ItemExistsException e){
> > 		}catch (PathNotFoundException e) {
> > 		} catch (RepositoryException e) {
> > 		}
> >     	}The jcr-ds.xml file has the following:<connection-factories>    <tx-connection-factory>
    <jndi-name>jcr/local</jndi-name>      <xa-transaction/>     <rar-name>jackrabbit-jca-2.1.0.rar</rar-name>
    <connection-definition>javax.jcr.Repository</connection-definition>     <config-property
name="homeDir" type="java.lang.String">D:\repositoryJR</config-property>     <config-property
name="configFile" type="java.lang.String">repository.xml</config-property>     <config-property
name="repositoryURI" type="java.lang.String">jcr-jackrabbit://jackrabbit</config-property>
    <config-property name="bindSessionToTransaction" type="java.lang.Boolean">true</config-property>
  </tx-connection-factory></connection-factories>When the session.logout() is
executed, I got the "Inactive logical session handle called" exception.Is this because the
session is already closed when JTA transaction commits? How should I fix this problem?thanks
a lot.Jason 		 	   		
> >    
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message