Hi,
I'm using AEM 5.6.1 and would like to know how I can access CRX Node using standalone java code.
Thanks
Siva
Solved! Go to Solution.
Views
Replies
Total Likes
Views
Replies
Total Likes
Hi Scott,
Thanks for your reply. I've followed the link and wrote a standalone java class to create crx node. I'm getting below exception:
javax.jcr.RepositoryException: Unable to access a repository with the following settings:
org.apache.jackrabbit.repository.uri: http://localhost:1304/crx/server
The following RepositoryFactory classes were consulted:
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:204)
at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:244)
at com.example.GetRepository.main(GetRepository.java:25)
Instance: AEM 5.6.1
JAVA CLASS:
/*
* This Java Quick Start uses the jackrabbit-standalone-2.4.0.jar
* file. See the previous section for the location of this JAR file
*/
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import javax.jcr.Node;
import org.apache.jackrabbit.commons.JcrUtils;
import org.apache.jackrabbit.core.TransientRepository;
public class GetRepository {
public static void main(String[] args) throws Exception {
try {
//Create a connection to the CQ repository running on local host
Repository repository = JcrUtils.getRepository("http://localhost:1304/crx/server");
//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();
// Store content
Node adobe = root.addNode("adobe");
Node day = adobe.addNode("day");
day.setProperty("message", "DAY CQ is part of the Adobe Digital Marketing Suite!");
// Retrieve content
Node node = root.getNode("adobe/day");
System.out.println(node.getPath());
System.out.println(node.getProperty("message").getString());
// Save the session changes and log out
session.save();
session.logout();
}
catch(Exception e){
e.printStackTrace();
}
}
}
Please let me know if I"m doing anything wrong.
Thanks In Advance
Views
Replies
Total Likes
Views
Replies
Total Likes
HI this Java quick start has been tested many times and it was just tested with AEM 5.6.1. Here are the results:
[img]TestJCR.png[/img]
If you have an exception -- try these things:
1 - Did you include the proper JAR file in your apps Class Path?
2 - are you using the correct server url and port?
3 - are you using the correct user name and password?
4- Is your server running?
Thanks
Views
Replies
Total Likes
Views
Likes
Replies