How to use RMI to connect CRX from an external application


How do I use RMI to connect to CRX from an external application ?

Answer, Resolution

The RMI connection listener is configured in web.xml of the crx web application. In a default installation, the war file is extracted to crx_install_dir/server/runtime/0/_crx/. You can find web.xml under crx_install_dir/server/runtime/0/_crx/WEB-INF/webxml.

Per default, RMI is not enabled, in order to enable it you need to:

  1. Edit web.xml and comment out the following lines under Repository Servlet
      The RMI port for registering the repository in the RMI Registry.
      If equals 0, the default port is used. Omit this parameter to
      disable RMI server entirely.

  2. Restart CRX and make sure that your server is listening on defined port (you can use unix command : lsof -i)
  3. Write a java class that connects to CRX through RMI. Below is a very simple example showing how to login to the CRX and get a Crx Session:
    import javax.jcr.Repository;
    import javax.jcr.Session;
    import javax.jcr.SimpleCredentials;
    import org.apache.jackrabbit.rmi.client.ClientRepositoryFactory;
     * Simple CRX RMI test class that connects to the CRX and logs in as admin
    public class RMITest {
     public static void main (String[] args){
      ClientRepositoryFactory factory = new ClientRepositoryFactory();
      Repository repository;
      String crxApplicationName = "crx";
      String repoUrl = "//localhost:1234/"+crxApplicationName; 
      String workspace = "crx.default";
      String username = "admin";
      char [] password = "admin".toCharArray();
      try {
       repository = factory.getRepository(repoUrl);
       Session s = repository.login(new SimpleCredentials(username,password), workspace);
      } catch (Exception e) {


Make sure that you have following jar files in place for this to work,







Get help faster and easier

New user?