Tuesday, July 20, 2010

Setting up shared Jackrabbit content repository

There are several deployment models which are described in detail by Jackrabbit. For our purpose the "Model 2: Shared J2EE Resource" seems to be the best applicable. This way to deploy a repository is to make it visible as a resource to all the web applications that are running inside a servlet container by registering the repository as a resource adapter to the application server. The repository is started and stopped with the application server. I'm going to describe all necessary steps for the GlassFish application server:

Open up "Resources/JNDI/Custom Resources" in the GlassFish administration console
  • Put in a JNDI name "jcr/repository"
  • Put in a resource type "javax.jcr.Repository"
  • Put in the factory class "org.apache.jackrabbit.core.jndi.BindableRepositoryFactory"
  • Create the property configFilePath, pointing to a configuration XML file with an absolute path on the server, e.g. "c:/repository/repository.xml"
  • Create the property repHomeDir pointing to the absolute filesystem path for the repository, e.g. "c:/repository"
Copy Jackrabbit dependencies to GLASSFISH_HOME/glassfish/domains/domain1/lib/ext. These are in case of Jackrabbit 1.6.2:
 mysql-connector-java-5.1.12-bin.jar (if datastore is MySQL)
To configure resource factory in Tomcat, add a <Resource> element to the <Context> in the file context.xml (global) or in the server.xml (for specific web app)
<Context ...>
  <Resource name="jcr/repository" auth="Container"
Jackrabbit dependencies have to be copied  to TOMCAT_HOME/lib. Now you can set up JNDI reference to jcr/repository and use JCR to manage content in the application server. The configured resource needs to be declared in the web.xml file:
    <description>JCR Repository</description>  
After all steps the repository will be created automatically by the registered above factory class.


  1. HI Oleg,
    I have implemented JackRabbit DMS.
    My only probelm is that when i deploy it linux, it fails every time. But when i manually delete repo home directory, it works. Note that I haven't mentioned jackrabbit dependency in web.xml. Could this be the problem?

    1. Sorry, I don't know. I don't develop DMS anymore :-)


Note: Only a member of this blog may post a comment.