Hi All,
I'm using an sql2 query to fetch all the home pages from different locales based on sling:resourceType and my query is below. I'm using system user to get the resolver. FYI.
SELECT * FROM [cq:Page] AS s WHERE s.[jcr:content/sling:resourceType] = 'sample/components/structure/pageHome' AND ISDESCENDANTNODE('/content/sample')
The above query is working fine in my local . But in Development environment I'm unable to fetch the home pages using this query from backend, whereas the same query I tried with crx/de query search where I'm able to fetch the homepages. I tried the below things but no luck,
Checked the system user permissions in user admin (which I used to get the resolver) and I'm having read, modify, delete, readACL, editACL for all .
Checked the backend logs. After executing the above query from backend I'm getting zero results. So, suspecting it should be permission issue. Can anyone help me to fix this?
Arun Patidar smacdonald2008 Ratna Kumar
Regards,
Vijay
Solved! Go to Solution.
Views
Replies
Total Likes
Hi All,
Thank you very much for your inputs. The has been fixed and it was due to the permission issue which I given for service user.
Regards,
Vijay
Views
Replies
Total Likes
Hi,
How did you get the session, the session should be repository session.
@Reference | |
private SlingRepository repository; |
session = repository.loginService("readService",null);
final Query query=session.getWorkspace().getQueryManager().createQuery("yourquery",Query.JCR_SQL2);
Views
Replies
Total Likes
Are you seeing any error message - if everything is setup the same way - it will work.
Views
Replies
Total Likes
Can you try your query in crx/de, so that you can see whether results are coming with your query. It will help to understand if there any issues with the query or values passed with the query
Views
Replies
Total Likes
here is the sample working example
aem63app-repo/SimpleSQL2SearchServlet.java at master · arunpatidar02/aem63app-repo · GitHub
Views
Replies
Total Likes
Hi Arun Patidar,
I have changed the code as you suggested (using repository session). But still I'm facing the same issue. The updated code is working fine in my local instance but not in dev. Also I' having some existing projects in dev environment where I'm using the same logic (get all locale based home pages) and the same code is working for those projects. But the same code is not working in fresh/new project. In logs I could see the sql2 query which got executed and it return zero results whereas the same query I tried with crx/de query search and I'm getting the proper results..FYI. I checked with Apache Sling Service User Mapper Service Amendment and I'm having proper mappings as well. Any other clue on this?
The query is : SELECT * FROM [cq:Page] AS s WHERE s.[jcr:content/sling:resourceType] = 'sample/components/structure/pageHome' AND ISDESCENDANTNODE('/content/sample')
I believe there is no issue in the query
Regards,
Vijay
Views
Replies
Total Likes
Can you check the the state of bundle of new project and service/servlet state also.
could be issue with archtype or dependencies.
Views
Replies
Total Likes
Hi Arun,
The state of the bundle is in active and the service is also in active. That's why I could able to see the logs which I put in that service.
If the issue with archtype or dependencies then it should not work in local as well right? but for me it is working in local. Issue is only wth the dev environment.
Regards,
Vijay
Views
Replies
Total Likes
Try to use AEM Chrome plugin: AEM Chrome Plug-in - Chrome Web Store,
It will allow you to see teh exact query that your code executes, determine if it's traversal and hence you need to work with indexes and test the query output from AEM Chrome Plugin in AEM Explain Query tool.
Views
Replies
Total Likes
Could you share the service user mapping xml/screenshot?
Is the code-bundle where this query is written, given appropriate permissions via service user mapping?
Does that service user has read (or appropriate) access on the folder path where your query runs (/content/sample)?
Could you enable logging on your package/query to see the error in logs?
Views
Replies
Total Likes
Hi All,
Thank you very much for your inputs. The has been fixed and it was due to the permission issue which I given for service user.
Regards,
Vijay
Views
Replies
Total Likes
Can you please guide me. I am facing the same issue.
Views
Replies
Total Likes
Check the system user permission..
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies