jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting" <jukka.zitt...@gmail.com>
Subject Re: repository shutdown
Date Sat, 15 Apr 2006 18:30:33 GMT

On 4/15/06, Torgeir Veimo <torgeir@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

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

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.


Jukka Zitting

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