title: Jackrabbit Oak: Getting started and connect to a standalone repository via RMI
body: <p>I am totally new to Jackrabbit and Jackrabbit Oak. I worked a lot with Alfresco though, another JCR compliant open-source content repo.</p>
  
  <p>I want to start a standalone Jackrabbit Oak repo, then connect to it via Java code. Unfortunately the Oak documentation is quite scarce.</p>
  
  <p>I checked out the Oak repo, built it with <code>mvn clean install</code> and then ran the standalone server (memory repository is fine for me at the moment for testing) via:</p>
  
  <pre><code>$ java -jar oak-run-1.6-SNAPSHOT.jar server
  
  Apache Jackrabbit Oak 1.6-SNAPSHOT
  Starting Oak-Memory repository -&gt; http://localhost:8080/
  13:14:38.317 [main] WARN  o.a.j.s.r.d.ProtectedRemoveManager - protectedhandlers-config is missing -&gt; DIFF processing can fail for the Remove operation if the content toremove is protected!
  </code></pre>
  
  <p>When I open <a href="http://localhost:8080/" rel="nofollow">http://localhost:8080/</a> I see a blank page with code like this but the html / xhtml output as source like this:</p>
  
  <p><a href="https://i.stack.imgur.com/uvG6p.png" rel="nofollow"><img src="https://i.stack.imgur.com/uvG6p.png" alt="enter image description here"></a></p>
  
  <p>I try to connect via Java code:</p>
  
  <pre><code>JcrUtils.getRepository("http://localhost:8080");
  // or
  JcrUtils.getRepository("http://localhost:8080/rmi");
  </code></pre>
  
  <p>but getting:</p>
  
  <pre><code>Connecting to http://localhost:8080
  Exception in thread "main" javax.jcr.RepositoryException: Unable to access a repository with the following settings:
      org.apache.jackrabbit.repository.uri: http://localhost:8080
  The following RepositoryFactory classes were consulted:
      org.apache.jackrabbit.oak.jcr.OakRepositoryFactory: declined
      org.apache.jackrabbit.commons.JndiRepositoryFactory: declined
  Perhaps the repository you are trying to access is not available at the moment.
      at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:223)
      at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:263)
      at Main.main(Main.java:26)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:483)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
  </code></pre>
  
  <p>(The Oak documentation is not as complete as the Jackrabbit documentation, but I am also not sure how much of Jackrabbit 2 is still valid for Oak, since it's a complete rewrite.)</p>
  
  <p>I found the <a href="http://jackrabbit.510166.n4.nabble.com/How-to-connect-to-OAK-standalone-server-td4663274.html" rel="nofollow">same question in the mailing list/Nabble</a>, but the provided answer there does not use a remote, standalone repository but a local one running in the same servlet container and even app (just that eventually the Mongo DB / Node store is configured as remote, but that would mean that the Mongo ports would need to be open). So the app creates the repository itself, which is not my case (I got this case working fine in Oak as well). </p>
  
  <p>In Jackrabbit2 (not Oak), I can simply connect via</p>
  
  <pre><code>Repository repo = new URLRemoteRepository("http://localhost:8080/rmi");
  </code></pre>
  
  <p>and it's working fine, but this method is not available for Oak, it seems.</p>
  
  <p>Is RMI not enabled by default in Oak? Is there a different URI to use?</p>
  
  <p>However, the <a href="http://jackrabbit.apache.org/oak/docs/use_getting_started.html" rel="nofollow">documentation of Oak</a> says "Oak comes with a runnable jar" and the <a href="https://github.com/apache/jackrabbit-oak/blob/trunk/oak-run/README.md" rel="nofollow">runnable jar</a> offers the <code>server</code> method to start the server, so I assume that my scenario above is a valid one.</p>