I tried to access a repository in a component using the code below. This code below do not work in CQ5.6.1. This code is from http://dev.day.com/docs/en/crx/current/developing/examples.html.
Error comes from line 73(Repository repository = JcrUtils.getRepository(uri);).
Can you please show why this does not work?
Thanks in advance.
[code]
String uri = "jndi://crx"
+ "?org.apache.jackrabbit.repository.jndi.name=crx"
+ "&java.naming.provider.url=http://jcr.day.com"
+ "&java.naming.factory.initial"
+ "=com.day.util.jndi.provider.MemoryInitialContextFactory";
// With CRX 2.2 or higher the above URI can be simplified to:
Repository repository = JcrUtils.getRepository(uri);
[error]
Caused by: org.apache.sling.api.SlingException: An exception occurred processing JSP page /apps/xxx/components/content/dbconnection/dbconnection.jsp at line 73
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.handleJspExceptionInternal(JspServletWrapper.java:683) at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:608) at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:525) at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:449) at org.apache.sling.scripting.jsp.JspScriptEngineFactory.callJsp(JspScriptEngineFactory.java:265) at org.apache.sling.scripting.jsp.JspScriptEngineFactory.access$100(JspScriptEngineFactory.java:87) at org.apache.sling.scripting.jsp.JspScriptEngineFactory$JspScriptEngine.eval(JspScriptEngineFactory.java:465) at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:361) ... 181 more Caused by: javax.jcr.RepositoryException: Unable to access a repository with the following settings: org.apache.jackrabbit.repository.uri: jndi://com.day.util.jndi.provider.MemoryInitialContextFactory/crx The following RepositoryFactory classes were consulted: Perhaps the repository you are trying to access is not available at the moment. at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:219) at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:259) at org.apache.jsp.apps.gnb.components.content.dbconnection.dbconnection_jsp._jspService(dbconnection_jsp.java:245) at org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:502) ... 186 more
Solved! Go to Solution.
Views
Replies
Total Likes
Hello,
It is not recommended to use JNDI to access repository outside CRX. Please use WebDav instead. Here is example http://wemcode.wemblog.com/accessrepository
This will be as simple as Repository repository = JcrUtils.getRepository("http://localhost:7402/crx/server"); Also make sure that you have required jar files in your class path.
You might also want to see http://forums.adobe.com/message/4734716 in case you need some additional jar files in your standalone application classpath.
Yogesh
Views
Replies
Total Likes
Hello,
It is not recommended to use JNDI to access repository outside CRX. Please use WebDav instead. Here is example http://wemcode.wemblog.com/accessrepository
This will be as simple as Repository repository = JcrUtils.getRepository("http://localhost:7402/crx/server"); Also make sure that you have required jar files in your class path.
You might also want to see http://forums.adobe.com/message/4734716 in case you need some additional jar files in your standalone application classpath.
Yogesh
Views
Replies
Total Likes