jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Jackson <aaron.jack...@gmail.com>
Subject Re: shutting down repository obtained from jndi via spring
Date Thu, 29 Sep 2005 06:30:02 GMT
Checkout the RepositoryFactoryBean in the sandbox of the SpringModules
project (https://springmodules.dev.java.net/). This factory bean takes care
of shutting down the repository correctly. It also offers the jcrTemplate
for simplifying many of the common JCR actions and an
OpenSessionInViewFilter that will maintain an open JCR Session throughout
the lifetime of a request.. I am using it in my webapp and it works great.

Thanks to Costin Leau for this great addition to the SpringModules.

Aaron Jackson

Here are the bean entries I added to my application context:

<bean id="repository" class="
<!-- normal factory beans params -->
<property name="configuration" value="classpath:jackrabbit-repo.xml"/>
<property name="homeDir" value="file:/repository"/>

<bean id="jcrSessionFactory" class="org.springmodules.jcr.JcrSessionFactory
<property name="repository" ref="repository"/>
<property name="credentials">
<bean class="javax.jcr.SimpleCredentials">
<constructor-arg index="0" value="bogus"/>
<!-- create the credentials using a bean factory -->
<constructor-arg index="1">
<bean factory-bean="password"

<!-- create the password to return it as a char[] -->
<bean id="password" class="java.lang.String">
<constructor-arg index="0" value="pass"/>

<bean id="jcrTemplate" class="org.springmodules.jcr.JcrTemplate">
<property name="sessionFactory" ref="jcrSessionFactory"/>
<property name="allowCreate" value="true"/>

On 9/28/05, Brian Moseley <bcm@osafoundation.org> wrote:
> i know at least a few folks here use spring with jackrabbit, so i'm
> asking this question here first in hopes that somebody has already
> solved the problem.
> i'm using spring's JndiObjectFactoryBean to obtain the Repository i've
> set up as a naming resource in tomcat.
> since updating to the latest jackrabbit source, i'm finding that a
> normal server shutdown does not cause the repository to be shutdown. the
> repository lock file is not removed, and i can not successfully reopen
> the repository when restarting tomcat.
> i tried using a destroy method on my bean (see below), but i got an
> error from DefaultListableBeanFactory that "Couldn't find a destroy
> method named 'shutdown' on bean with name 'jcrRepository'".
> <bean id="jcrRepository"
> class="org.springframework.jndi.JndiObjectFactoryBean"
> destroy-method="shutdown">
> <property name="jndiName">
> <value>jcr/cosmo</value>
> </property>
> <property name="resourceRef">
> <value>true</value>
> </property>
> </bean>
> destroy-method works fine in my test environment, where i instantiate
> RepositoryImpl directly.
> <bean id="jcrRepositoryConfig"
> class="org.apache.jackrabbit.core.config.RepositoryConfig"
> factory-method="create">
> <constructor-arg type="java.lang.String" index="0">
> <value>@CONFIGFILEPATH@</value>
> </constructor-arg>
> <constructor-arg type="java.lang.String" index="1">
> </constructor-arg>
> </bean>
> <bean id="jcrRepository"
> class="org.apache.jackrabbit.core.RepositoryImpl"
> destroy-method="shutdown">
> <constructor-arg>
> <ref local="jcrRepositoryConfig"/>
> </constructor-arg>
> </bean>
> any suggestions? i *really* don't want to have to write a servlet
> context listener to shut jackrabbit down. i have thus far managed to
> keep jackrabbit-specific code out of the webapp and would like to keep
> it that way.
> thanks!

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message