9

I need to work with remote jackrabbit repository. I use following code to connect to the local repository:

Repository repository = new TransientRepository();
Session session = repository.login(new SimpleCredentials("username", "password".toCharArray()));

and this works for the local repository but what do I do incase of the remote jackrabbit?

Abhishek Dhote
  • 1,638
  • 10
  • 41
  • 62

3 Answers3

6

Have you tried using this?

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

Repository repository = JcrUtils.getRepository("http://$SERVER_ADDRESS:$PORT/$CONTEXT");

That should work if the remote repository is exposing RMI services. Please note that RMI access is in general considered to be quite slow.

You'll find more info about accessing remote repositories here.

abahgat
  • 13,360
  • 9
  • 35
  • 42
6

Another option is WebDav, which is supposed to be somewhat faster than RMI, though not as fast as the native interface:

import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;

import org.apache.jackrabbit.commons.JcrUtils;

public class main {

/**
 * @param args
 */
public static void main(String[] args) throws Throwable{
    String url = "http://localhost:8080/server";
    System.out.println("Connecting to " + url);
    Repository repository = JcrUtils.getRepository(url);
    SimpleCredentials creds = new SimpleCredentials("admin",
            "admin".toCharArray());
    Session jcrSession = repository.login(creds, "default");
    System.out.println("Login successful, workspace: " + jcrSession.getWorkspace());
Dan
  • 364
  • 1
  • 2
  • I'm using both at the moment. There is no way WebDAV is faster than RMI in Jackrabbit. Where does it say so? Also WebDAV doesn't provide nearly the same amount of functionality. – user207421 Sep 09 '12 at 07:44
  • Hello, EJP, I would like to update a node, but RMI and webdav failed. can you provide an example on how you do ? – Grégory Dec 04 '12 at 22:19
  • You'll need to add the correct dependencies to the project. To use the webdav connector, you need to add jackrabbit-jcr2dav to your classpath: http://search.maven.org/remotecontent?filepath=org/apache/jackrabbit/jackrabbit-jcr2dav/2.6.0/jackrabbit-jcr2dav-2.6.0.jar – ilikeorangutans Apr 03 '13 at 17:17
2

We're using the REST interface provided by Sling to remotely access our repository.

Vinnie
  • 12,400
  • 15
  • 59
  • 80
  • How can we access a stand alone rackrabbit server through Sling without using its launch pad. I believe it should be a change in configuration. But where? Thanks. – Bee Jun 03 '12 at 07:56
  • 2
    I can't remember how I accomplished this. We're not using Sling any longer. I think we found the API too confusing/limiting or maybe it didn't have some functionality we were looking for (maybe it was the ability to encrypt files?). I wrote my own simplified REST API to call the Jackrabbit API. Good luck! – Vinnie Jun 04 '12 at 13:33
  • @Vinnie Hi Vinnie, could you share some more info on the rest spi you wrote for accessing remote repository? Is it faster than RMI or webdav?? – Gandhi Aug 21 '17 at 08:02