Follow the below steps to access the CQ5 JCR repository (CRX) remotely.
A code snippet for the above can be found below
- Construct the remote URL of your CQ instance.
- e.g. http://localhost:4502/crx/server
- Where localhost is the host where CQ is running & 4502 is port where CQ is listening to the requests.
- Get the repository by using the JCRUtils class which is available in the jackrabbit-jcr-commons.jar library.
- repository = JcrUtils.getRepository("http://localhost:4502/crx/server");
- Create a SimpleCredential object by passing username, password entries.
- SimpleCredentials creds = new SimpleCredentials("admin", "admin".toCharArray());
- Invoke the login method of repository object by passing the credential object & the workspace name.
- Session session = repository.login(creds, "crx.default");
A code snippet for the above can be found below