How to access remote jackrabbit repository?
Solution 1
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());
Solution 2
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.
Solution 3
We're using the REST interface provided by Sling to remotely access our repository.
Related videos on Youtube
Abhishek Dhote
A Hewlett Packard long-timer, innovator and a products guy with keen interest in social entrepreneurship. Built and architected enterprise products at HP. Conceptualization and developed products, launched social startup, hired people and working on growing team and revenue to profitability.
Updated on May 16, 2022Comments
-
Abhishek Dhote about 2 years
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?
-
Bee about 12 yearsHow 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.
-
Vinnie about 12 yearsI 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!
-
user207421 almost 12 yearsI'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.
-
Grégory over 11 yearsHello, EJP, I would like to update a node, but RMI and webdav failed. can you provide an example on how you do ?
-
ilikeorangutans about 11 yearsYou'll need to add the correct dependencies to the project. To use the webdav connector, you need to add jackrabbit-jcr2dav to your classpath: search.maven.org/remotecontent?filepath=org/apache/jackrabbit/…
-
Gandhi almost 7 years@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??
-
Coderino Javarino about 2 yearsyour link asks for a log in