Querying Adobe Experience Manager Data using the JCR API [Error] | Community
Skip to main content
Level 2
October 16, 2015
Solved

Querying Adobe Experience Manager Data using the JCR API [Error]

  • October 16, 2015
  • 13 replies
  • 2640 views

hi, im doing this tutorial about querys to JCR:

http://helpx.adobe.com/adobe-cq/using/querying-experience-manager-data-using.html

everything went smoothly, and i have everything up and running, i can add data (customers) and thats working, but when i try to see the list, im getting an error. Here is the stacktrace:

org.apache.jackrabbit.core.SessionImpl Unclosed session detected. The session was opened here:  java.lang.Exception: Stack Trace at org.apache.jackrabbit.core.SessionImpl.<init>(SessionImpl.java:222) at org.apache.jackrabbit.core.XASessionImpl.<init>(XASessionImpl.java:117) at com.day.crx.core.CRXSessionImpl.<init>(CRXSessionImpl.java:69) at com.day.crx.core.CRXRepositoryImpl.createSessionInstance(CRXRepositoryImpl.java:935) at org.apache.jackrabbit.core.RepositoryImpl.createSession(RepositoryImpl.java:959) at org.apache.jackrabbit.core.SessionFactory.createAdminSession(SessionFactory.java:42) at com.day.crx.sling.server.impl.SlingRepositoryWrapper.loginAdministrative(SlingRepositoryWrapper.java:76) at com.adobe.cq.CustomerServiceImp.getCustomerData(CustomerServiceImp.java:159) at org.apache.jsp.apps.jcrpersist.components.page.templateQuery.query_json_jsp._jspService(query_json_jsp.java:153) 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) 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) at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:171) at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:463) at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:508) at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:45) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64) at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilterWithErrorHandling(WCMDebugFilter.java:182) at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilter(WCMDebugFilter.java:149) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.day.cq.wcm.core.impl.WCMComponentFilter.filterRootInclude(WCMComponentFilter.java:356) at com.day.cq.wcm.core.impl.WCMComponentFilter.doFilter(WCMComponentFilter.java:168) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.day.cq.personalization.impl.TargetComponentFilter.doFilter(TargetComponentFilter.java:96) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:254) at org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:49) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64) at com.day.cq.wcm.core.impl.AuthoringUIModeServiceImpl.doFilter(AuthoringUIModeServiceImpl.java:301) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.day.cq.wcm.core.impl.warp.TimeWarpFilter.doFilter(TimeWarpFilter.java:106) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.day.cq.wcm.mobile.core.impl.redirect.RedirectFilter.doFilter(RedirectFilter.java:290) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.adobe.cq.commerce.hybris.impl.LoginRequestFilter.doFilter(LoginRequestFilter.java:56) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:64) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.day.cq.wcm.foundation.forms.impl.FormsHandlingServlet.doFilter(FormsHandlingServlet.java:221) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.day.cq.theme.impl.ThemeResolverFilter.doFilter(ThemeResolverFilter.java:76) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.adobe.granite.optout.impl.OptOutFilter.doFilter(OptOutFilter.java:74) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.day.cq.wcm.core.impl.WCMRequestFilter.doFilter(WCMRequestFilter.java:90) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.adobe.cq.history.impl.HistoryRequestFilter.doFilter(HistoryRequestFilter.java:107) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.day.cq.wcm.designimporter.CanvasPageDeleteRequestFilter.doFilter(CanvasPageDeleteRequestFilter.java:88) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at org.apache.sling.rewriter.impl.RewriterFilter.doFilter(RewriterFilter.java:83) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at org.apache.sling.i18n.impl.I18NFilter.doFilter(I18NFilter.java:127) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at org.apache.sling.bgservlets.impl.BackgroundServletStarterFilter.doFilter(BackgroundServletStarterFilter.java:135) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processRequest(SlingRequestProcessorImpl.java:151) at org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:206) at org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96) at org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79) at org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42) at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49) at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33) at org.apache.sling.i18n.impl.I18NFilter.doFilter(I18NFilter.java:127) at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88) at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76) at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47) at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33) at org.apache.felix.http.sslfilter.internal.SslFilter.doFilter(SslFilter.java:55) at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88) at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76) at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47) at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33) at org.apache.sling.security.impl.ReferrerFilter.doFilter(ReferrerFilter.java:263) at org.apache.felix.http.base..

 

i guess it has something to do with this code line (line 159 of CustomerService.java):

Session session = this.repository.loginAdministrative(null);

because it does say it has to do with the session, and it mentions the line in the stacktrace.

but i dont know what should be done, can someone tell me how to proceed? to make this work?

 

thanks in advance!!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

I have been thinking about this somewhat -- i think i know what happened -- you took code from another article that talks about just Persisting Data into the AEM JCR. The code you had in your Java for injestCustData was from that article and when you switched to this article - you did not update the injestCustData method (take the code from this article). I have updated the code in the Persisting Data in the AEM JCR so if somebody happens to merge code like this again from different articles - they will not run into the issue. 

13 replies

smacdonald2008
Level 10
October 16, 2015

Actually - i am a bit confused -- in your Java code:

 

//Create a node that represents the root node Node root = session.getRootNode(); //Get the content node in the JCR Node content = root.getNode("content"); //Determine if the content/customer node exists Node customerRoot = null; int custRec = doesCustExist(content); //-1 means that content/customer does not exist if (custRec == -1) { //content/customer does not exist -- create it customerRoot = content.addNode("customer"); } else { //content/customer does exist -- retrieve it customerRoot = content.getNode("customer"); } int custId = custRec+1; //assign a new id to the customer node //Store content from the client JSP in the JCR Node custNode = customerRoot.addNode("customer"+firstName+lastName+custId);

 

 

But in the article -- we made the customer nodes nt:unstructured:
 

//-1 means that content/customer does not exist
 if (custRec == -1)
     //content/customer does not exist -- create it
    customerRoot = content.addNode("customer","sling:OrderedFolder");
 else
   //content/customer does exist -- retrieve it
   customerRoot = content.getNode("customer");
                                
   int custId = custRec+1; //assign a new id to the customer node
                     
   //Store content from the client JSP in the JCR
   Node custNode = customerRoot.addNode("customer"+firstName+lastName+custId,"nt:unstructured");

 

 

Wonder why "nt:unstructured" was not part of your Java code. For future reference - when adding a node to the AEM JCR - be sure to specify a type.

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

I have been thinking about this somewhat -- i think i know what happened -- you took code from another article that talks about just Persisting Data into the AEM JCR. The code you had in your Java for injestCustData was from that article and when you switched to this article - you did not update the injestCustData method (take the code from this article). I have updated the code in the Persisting Data in the AEM JCR so if somebody happens to merge code like this again from different articles - they will not run into the issue. 

kornjjuanAuthor
Level 2
October 16, 2015

you are right! i did the other tutorial first and didnt update that method, ill change it to have the nt:unestructured structure as intended.

 

thank you!