Edgar Poce wrote:
To prevent the above situation you should try to create only one instance and share it across all the webapps. You can do it through JNDI (see configuration example below). See Model 2 at http://incubator.apache.org/jackrabbit/arch/deploy.html.
right. i failed to be as specific as i planned. this is exactly what i've been trying to do.
my first attempt was to use BindableRepositoryFactory to register a J2EE resource, but i was using javax.jcr.Repository as the resource type rather than BindableRepository. BindableRepositoryFactory complained about its reference not being a BindableRepository (or maybe returned null, don't recall). clearly i didn't know what i was doing ;)
i then wrote my own simple factory class that returned an instance of RepositoryImpl. even though the class returned a singleton instance, i noticed that each webapp got its own instance. that definitely didn't seem right to me, but it was the closest i got to anything working.
I think a "shared J2EE Resource" means one instance for multiple apps and not one persistent storage for multiple jackrabbit instances.
right. that's definitely what i want.
A model 2 configuration example for Tomcat 4.x (see tomcat docs):
ok, i used this configuration, configuring a global resource for the repository factory and adding resource links to each of my webapps' context config files (see below).
the first webapp to be started by tomcat successfully looks up the BindableRepository. great.
however, the second webapp fails. the JNDI lookup appears to succeed, but Spring throws a property conversion exception:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.apache.jackrabbit.core.jndi.BindableRepository] to required type [javax.jcr.Repository] for property 'repository'
this is a Spring exception, so i'm going to ask about that on the Spring list, but it sure seems like a bizarre problem, right? BindableRepository implements Repository, after all.
anyway, thanks for the pointers. using BindableRepository as the resource type (which should have been obvious) was what i was missing. now to figure out the Spring property conversion problem.
-----
server.xml:
<ResourceParams name="jcr/repositoryFactory">
<parameter>
<name>factory</name>
<value>
org.apache.jackrabbit.core.jndi.BindableRepositoryFactory
</value>
</parameter>
<parameter>
<name>configFilePath</name>
<value>etc/repository.xml</value>
</parameter>
<parameter>
<name>repHomeDir</name>
<value>data/repository</value>
</parameter>
</ResourceParams>webui.xml:
<ResourceLink name="jcr/repositoryFactory"
global="jcr/repositoryFactory"
type="org.apache.jackrabbit.core.jndi.BindableRepository"/>web.xml:
<resource-env-ref>
<resource-env-ref-name>jcr/repositoryFactory</resource-env-ref-name>
<resource-env-ref-type>
org.apache.jackrabbit.core.jndi.BindableRepository
</resource-env-ref-type>
</resource-env-ref>
