How to access JCR nodes using code
I am trying to retrieve the data from node and update as well.
This is the code that I am trying to run
try {
//Create a connection to the CQ repository running on local host
Repository repository = JcrUtils.getRepository("http://localhost:4502/crx/de/index.jsp#/content/launches/2021/09/16/Tool");
//Create a Session
javax.jcr.Session session = repository.login( new SimpleCredentials("admin", "admin".toCharArray()));
//Create a node that represents the root node
Node root = session.getRootNode();
// Retrieve content
Node node = root.getNode("jcr:content/sources/source_0");
LOG.info(node.getProperty("sourceRootResource").getString()+"This is sourceRootPath");
node.setProperty("sourceRootResource", "/content//websites/en_us/pyramid");
LOG.info("Property SET");
// Save the session changes and log out
session.save();
session.logout();
}
catch(Exception e){
LOG.error("Cant update node", e);
}
This is popping error.
The following RepositoryFactory classes were consulted:
Perhaps the repository you are trying to access is not available at the moment.