AEM-6.4 SQL2 query is not working from backend | Community
Skip to main content
vijays80591732
Level 3
May 3, 2019 7:33 AM UTC
Solved

AEM-6.4 SQL2 query is not working from backend

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
vijays80591732
vijays80591732Accepted solution
Level 3
May 7, 2019 8:33 AM UTC

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

12 replies

Ankur_Khare
New Participant
Oct 10, 2019 6:45 AM UTC

Check the system user permission..

Translate
New Participant
Oct 9, 2019 11:21 AM UTC

Can you please guide me. I am facing the same issue.

Translate
vijays80591732
vijays80591732AuthorAccepted solution
Level 3
May 7, 2019 8:33 AM UTC

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

Translate
Gaurav-Behl
Level 10
May 6, 2019 3:52 PM UTC

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?

Translate
Employee
May 6, 2019 3:03 PM UTC

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.

Translate
vijays80591732
Level 3
May 6, 2019 9:11 AM UTC

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

Translate
arunpatidar
New Participant
May 6, 2019 7:39 AM UTC

Can you check the the state of bundle of new project and service/servlet state also.

could be issue with archtype or dependencies.

Translate
Arun Patidar
vijays80591732
Level 3
May 6, 2019 7:35 AM UTC

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

Translate
arunpatidar
New Participant
May 4, 2019 10:29 AM UTC
Ravi_Pampana
New Participant
May 3, 2019 5:43 PM UTC

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

Translate