You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Torgeir Veimo <to...@pobox.com> on 2006/04/15 19:33:14 UTC

repository shutdown

What's the normal way to trigger a repository shutdown? 

I retrieve any repository instance through jndi in our webapp, and close
any open session when no longer in use, yet when we redeploy our webapp,
we get out-of-memory exceptions since the repository isn't being closed
down, causing the old webapp instance to remain in memory.

-- 
Torgeir Veimo <to...@pobox.com>


Re: repository shutdown

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 4/17/06, Torgeir Veimo <to...@pobox.com> wrote:
> > This doesn't really work if the repository is configured using jndi,
> > since the repository instance is a BindableRepository, which is a
> > package protected class, so you can't cast to it, and the shutdown
> > method is package protected as well.
>
> What about making BindableRepository implement JackrabbitRepository ?

Something like this was suggested earlier (see 
http://issues.apache.org/jira/browse/JCR-243), but the consensus then
was to use the RegistryHelper or some other mechanism to manage the
repository instance. See the related discussion thread for the
details.

BR,

Jukka Zitting

--
Yukatan - http://yukatan.fi/ - info@yukatan.fi
Software craftsmanship, JCR consulting, and Java development

Re: repository shutdown

Posted by Torgeir Veimo <to...@pobox.com>.
On Mon, 2006-04-17 at 14:02 +0200, Torgeir Veimo wrote:
> On Sat, 2006-04-15 at 21:30 +0300, Jukka Zitting wrote:
> > Hi,
> > 
> > On 4/15/06, Torgeir Veimo <to...@pobox.com> wrote:
> > > What's the normal way to trigger a repository shutdown?
> > >
> > > I retrieve any repository instance through jndi in our webapp, and close
> > > any open session when no longer in use, yet when we redeploy our webapp,
> > > we get out-of-memory exceptions since the repository isn't being closed
> > > down, causing the old webapp instance to remain in memory.
> > 
> > The preferred way to shut down a Jackrabbit repository is to call the
> > JackrabbitRepository.shutdown() method. (You can cast a Jackrabbit
> > Repository instance to the
> > org.apache.jackrabbit.api.JackrabbitRepository interface.) You can do
> > this for example in a Servlet.destroy() method of a model 1
> > deployment.
> 
> This doesn't really work if the repository is configured using jndi,
> since the repository instance is a BindableRepository, which is a
> package protected class, so you can't cast to it, and the shutdown
> method is package protected as well.

What about making BindableRepository implement JackrabbitRepository ?

-- 
Torgeir Veimo <to...@pobox.com>


Re: repository shutdown

Posted by Torgeir Veimo <to...@pobox.com>.
On Sat, 2006-04-15 at 21:30 +0300, Jukka Zitting wrote:
> Hi,
> 
> On 4/15/06, Torgeir Veimo <to...@pobox.com> wrote:
> > What's the normal way to trigger a repository shutdown?
> >
> > I retrieve any repository instance through jndi in our webapp, and close
> > any open session when no longer in use, yet when we redeploy our webapp,
> > we get out-of-memory exceptions since the repository isn't being closed
> > down, causing the old webapp instance to remain in memory.
> 
> The preferred way to shut down a Jackrabbit repository is to call the
> JackrabbitRepository.shutdown() method. (You can cast a Jackrabbit
> Repository instance to the
> org.apache.jackrabbit.api.JackrabbitRepository interface.) You can do
> this for example in a Servlet.destroy() method of a model 1
> deployment.

This doesn't really work if the repository is configured using jndi,
since the repository instance is a BindableRepository, which is a
package protected class, so you can't cast to it, and the shutdown
method is package protected as well.

-- 
Torgeir Veimo <to...@pobox.com>


Re: repository shutdown

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 4/18/06, Torgeir Veimo <to...@pobox.com> wrote:
> Ok, I'm now using a TransientRepository. There's no way to force a
> shutdown of it, even if not all sessions are logged out?

No, not really, but it shouldn't be a problem to add one. Please file
an enhancement request in Jira and I'll see what I can do.

BR,

Jukka Zitting

--
Yukatan - http://yukatan.fi/ - info@yukatan.fi
Software craftsmanship, JCR consulting, and Java development

Re: repository shutdown

Posted by Torgeir Veimo <to...@pobox.com>.
On Mon, 2006-04-17 at 18:19 +0300, Jukka Zitting wrote:
> 
> 
> On 4/16/06, Torgeir Veimo <to...@pobox.com> wrote:
> > A TransientRepository wouldn't be sufficient here, since it doesn't
> > actually persist any data?
> 
> It does persist the data. The naming is a bit unfortunate (my
> mistake), it refers to the transient nature of the underlying
> RepositoryImpl instance (it is only present when one or more sessions
> are open), not to whether the content data is persisted or not. 

Ok, I'm now using a TransientRepository. There's no way to force a
shutdown of it, even if not all sessions are logged out? 

On a webapp redeploy, it's not possible to get at all sessions and log
them out properly.

-- 
Torgeir Veimo <to...@pobox.com>


Re: repository shutdown

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 4/16/06, Torgeir Veimo <to...@pobox.com> wrote:
> A TransientRepository wouldn't be sufficient here, since it doesn't
> actually persist any data?

It does persist the data. The naming is a bit unfortunate (my
mistake), it refers to the transient nature of the underlying
RepositoryImpl instance (it is only present when one or more sessions
are open), not to whether the content data is persisted or not.

> What's exactly the issue with the repository that prevents gc when all
> sessions are closed?

The RepositoryImpl class sets up quite a few internal data structures
that are shared by all the sessions. These data structures are only
released when shutdown() is called, not when sessions are closed.

BR,

Jukka Zitting

--
Yukatan - http://yukatan.fi/ - info@yukatan.fi
Software craftsmanship, JCR consulting, and Java development

Re: repository shutdown

Posted by Torgeir Veimo <to...@pobox.com>.
On Sat, 2006-04-15 at 21:30 +0300, Jukka Zitting wrote:
> Hi,
> 
> On 4/15/06, Torgeir Veimo <to...@pobox.com> wrote:
> > What's the normal way to trigger a repository shutdown?
> >
> > I retrieve any repository instance through jndi in our webapp, and close
> > any open session when no longer in use, yet when we redeploy our webapp,
> > we get out-of-memory exceptions since the repository isn't being closed
> > down, causing the old webapp instance to remain in memory.
> 
> The preferred way to shut down a Jackrabbit repository is to call the
> JackrabbitRepository.shutdown() method. (You can cast a Jackrabbit
> Repository instance to the
> org.apache.jackrabbit.api.JackrabbitRepository interface.) You can do
> this for example in a Servlet.destroy() method of a model 1
> deployment.

Is it possible to set up a model deployment while still configuring the
repository in the deployment descriptor of the webapp?

> Support for this feature is however not yet available in the
> BindableRepositoryFactory object factory so you'll need custom code to
> bind a TransientRepository to JNDI.

A TransientRepository wouldn't be sufficient here, since it doesn't
actually persist any data?

What's exactly the issue with the repository that prevents gc when all
sessions are closed?

-- 
Torgeir Veimo <to...@pobox.com>


Re: repository shutdown

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 4/15/06, Torgeir Veimo <to...@pobox.com> wrote:
> What's the normal way to trigger a repository shutdown?
>
> I retrieve any repository instance through jndi in our webapp, and close
> any open session when no longer in use, yet when we redeploy our webapp,
> we get out-of-memory exceptions since the repository isn't being closed
> down, causing the old webapp instance to remain in memory.

The preferred way to shut down a Jackrabbit repository is to call the
JackrabbitRepository.shutdown() method. (You can cast a Jackrabbit
Repository instance to the
org.apache.jackrabbit.api.JackrabbitRepository interface.) You can do
this for example in a Servlet.destroy() method of a model 1
deployment.

Things are a bit tricker in model 2 deployments where more than one
application uses the same repository. Probably the best way to handle
such situations is to use the JCA adapter in a full J2EE container, as
it will automatically handle repository shutdown, but in a plain web
container you still need an explicit shutdown() call. One way to do
that is to have a dedicated web application (like
jackrabbit-server-1.0.war) that handles repository startup and
shutdown, and shares the repository to other applications through
JNDI.

Yet another alternative is to use the TransientRepository class
instead of the RepositoryImpl class. A TransientRepository instance
will automatically intialize the repository when the first session is
started and shut it down when the last session is closed. Support for
this feature is however not yet available in the
BindableRepositoryFactory object factory so you'll need custom code to
bind a TransientRepository to JNDI.

BR,

Jukka Zitting

--
Yukatan - http://yukatan.fi/ - info@yukatan.fi
Software craftsmanship, JCR consulting, and Java development