Apache Jackrabbit : RemoteAccess

Remote Access


Jackrabbit supports remote access using DavEx (WebDAV with JCR extensions, since Jackrabbit 2.0) and an RMI layer called JCR-RMI.

The easiest way to access a remote repository is to use the org.apache.jackrabbit.commons.JcrUtils.getRepository(String uri) method from the jackrabbit-jcr-commons component. This method takes a repository URI, connects to it and returns a local javax.jcr.Repository instance that you can use to access the repository through the standard JCR API. Note that the JcrUtils class is only available starting with Jackrabbit 2.0.


Jackrabbit 2.0 supports the DavEx protocol through the Jackrabbit WebDAV server included in the Jackrabbit web application and the Standalone Server. The web application exposes the DavEx interface at http://<server>/<context>/server and the standalone server by default at http://localhost:8080/server.

On the client side, you need the following Maven dependencies:

<!-- JCR API -->
<!-- All the Jackrabbit libraries needed for DavEx, plus JcrUtils -->
<!-- The SFL4J logging implementation you prefer -->

Assuming you have the Jackrabbit standalone server running with default settings, you can then connect to it with the following code:

import javax.jcr.Repository;
import org.apache.jackrabbit.commons.JcrUtils;

Repository repository = JcrUtils.getRepository("http://localhost:8080/server");

See also org.apache.jackrabbit.commons.Jcr{{`Utils#get}}Repository(String), org.apache.jackrabbit.commons.JcrUtils#get`Repository(java.util.Map) and org.apache.jackrabbit.spi2davex.Spi2davex{{`Repository}}Service`Factory for applicable configuration parameters.


The JCR API can be accessed over RMI. Limitations: Jackrabbit over RMI is slow. The JCR 2.0 API is only partially supported in Jackrabbit 2.0 (most of the new JCR 2.0 methods simply throw UnsupportedRepositoryOperationExceptions).

The easiest way to access a Jackrabbit repository over RMI is to use the RMI endpoint that the Jackrabbit standalone jar exposes at http://localhost:8080/rmi. You need the following code snippet and the jackrabbit-jcr-rmi and jackrabbit-jcr-commons dependencies to connect to this endpoint:

import javax.jcr.Repository;
import org.apache.jackrabbit.commons.JcrUtils;

Repository repository = JcrUtils.getRepository("http://localhost:8080/rmi");

If you use Jackrabbit in embedded mode, you can expose your repository to remote clients by starting the RMI registry (if one is not already running) and binding the remote reference there:

// Start the RMI registry
Registry reg = LocateRegistry.createRegistry(1100);

// Bind the repository reference to the registry
Repository repository = ...;
ServerAdapterFactory factory = new ServerAdapterFactory();
RemoteRepository remote = factory.getRemoteRepository(repository);
reg.rebind("jackrabbit", remote);

Note that you need to keep an explicit local reference to the RemoteRepository object above to prevent the garbage collector from claiming it.

To connect to such a server, use:

import javax.jcr.Repository;
import org.apache.jackrabbit.commons.JcrUtils;

Repository repository = JcrUtils.getRepository("rmi://localhost:1100/jackrabbit");