Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Querying Adobe Experience Manager 6 data using the Sling getServiceResourceResolver method

Avatar

Level 4

Hi

I am working on the sample provided in the url populating the data in the data grid pulled from the JCR. I am facing the problem as the examples is not using the archetype10 to run the java code which was trained during the adobe training can someone help me on this.

Do we need to create a project structure like the company project provided in the screen shot which is an example project created during the adobe training.

https://helpx.adobe.com/experience-manager/using/querying-experience-manager-sling.html

Regards

Pr@veen

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Praveen,

As scott stated, you try creating the project structure under C:\AdobeCQ, it is very simple way for creating the project and build the directory, then you can see your project get created. 

I used to follow the same method for creating the project structure under the directory C:\AdobeCQ for working purposes. It works!! You need to include the POM files under bundle(POM) after you written your business logic.

Also archetype 10 is not required as stated. You can use the maven command as mentioned in article.

Thanks,
Ratna Kumar.

View solution in original post

10 Replies

Avatar

Level 9

@Praveen,

If you would like to learn multiple things in one go, I would personally feel that you should follow step by step. Generally, we like to skip some of the stuff, however, it is not good idea. Sometimes it is when you have gone through same material multiple times.

Praveen Kumar wrote...

Hi

I am working on the sample provided in the url populating the data in the data grid pulled from the JCR. I am facing the problem as the examples is not using the archetype10 to run the java code which was trained during the adobe training can someone help me on this.

Do we need to create a project structure like the company project provided in the screen shot which is an example project created during the adobe training.

https://helpx.adobe.com/experience-manager/using/querying-experience-manager-sling.html

Regards

Pr@veen

 

 

Avatar

Level 9

Praveen Kumar ,

Could be an honest mistake, Just to avoid confusion, remove all duplicate posts submitted by you.

Jitendra

Avatar

Level 4

Hi,

can someone help me to update for AEM6.1 as the example sample is using AEM5.5 and 5.6 archetype for build and deployment.

 

Regards

Pr@veen

Avatar

Level 10

If you follow this article and use the Maven command specified in the article - it will work.  This is a valid Maven command to build an OSGi bundle used in this article:

mvn archetype:generate -DarchetypeRepository=https://repo.adobe.com/nexus/content/groups/public/ -DarchetypeGroupId=com.day.jcr.vault -DarchetypeArtifactId=multimodule-content-package-archetype -DarchetypeVersion=1.0.2 -DgroupId=com.community.aem -DartifactId=slingjcr -Dversion=1.0-SNAPSHOT -Dpackage=com.community.aem -DappsFolderName=myproject -DartifactName="My Project" -DcqVersion="6.1" -DpackageGroup="My Company"

You do not need to run archetype10.

As mentioned by Jitendra S.Tomar - do not skip steps. 

Avatar

Level 4

Hi

After the mvn build how the following step

~~
Modify the Maven build is successful how the OSGI bundle for C:\AdobeCQ\customer\bundle gets generated  as I do not see the customer folder in C:/AdobeCQ folder

Below step for your reference
 
 

Modify the POM files to successfully build the OSGi bundle. In the POM file located at C:\AdobeCQ\customer\bundle, add the following dependencies.
•org.apache.felix.scr
•org.apache.felix.scr.annotations
•org.apache.jackrabbit
•org.apache.sling

The following XML represents this POM file.

Avatar

Level 10

You create your working folder as discussed in the article here: 

To keep things simple - the article uses C:\AdobeCQ as the working directory. So build this directory and run maven from within this directory. 

Once you run the Maven command - you will see this directory: C:\AdobeCQ\slingjcr. I will make sure this folder is always referenced in this article. 

Avatar

Correct answer by
Level 10

Hi Praveen,

As scott stated, you try creating the project structure under C:\AdobeCQ, it is very simple way for creating the project and build the directory, then you can see your project get created. 

I used to follow the same method for creating the project structure under the directory C:\AdobeCQ for working purposes. It works!! You need to include the POM files under bundle(POM) after you written your business logic.

Also archetype 10 is not required as stated. You can use the maven command as mentioned in article.

Thanks,
Ratna Kumar.

Avatar

Level 4

Hi Smacdonald,

when I try to enter the values from the http://localhost:4502/cf#/content/DataQUery.html and submit the add customer I am getting the below error when invoking the persisjason.jsp

 

An error occurred at line: 10 in the jsp file: /apps/jcrquery/components/page/templateQuery/persist.json.jsp
com.community.aem.CustomerService cannot be resolved to a type
7:
8:
9:  
10: com.community.aem.CustomerService cs = sling.getService(com.community.aem.CustomerService.class);
11:  
12: int myPK = cs.injestCustData(first, last, phone, desc) ;
13:   


An error occurred at line: 10 in the jsp file: /apps/jcrquery/components/page/templateQuery/persist.json.jsp
com.community.aem.CustomerService cannot be resolved to a type
7:
8:
9:  
10: com.community.aem.CustomerService cs = sling.getService(com.community.aem.CustomerService.class);
11:  
12: int myPK = cs.injestCustData(first, last, phone, desc) ;

Can you please help.

 

Regards

Pr@veen

Avatar

Level 10

I just re-tested article – it works nicely.

Your error indicates that the JSP cannot find the OSGi service. Try re-installing the OSGi service.

If you want – we can setup a connect session. 

Avatar

Level 4

~~Hi Scott,

Even with the new instance I am getting the error while invoking the persist.json.jsp below is the stack trace for your reference.  Can we have a quick connect today I have not got the skype approval yet but we will connect with your adobe connect.

15.01.2016 16:12:06.910 *ERROR* [0:0:0:0:0:0:0:1 [1452854526904] GET /content/DataQUery/_jcr_content.persist.json HTTP/1.1] com.day.cq.wcm.core.impl.WCMDebugFilter Error during include of SlingRequestPathInfo: path='/content/DataQUery/jcr:content', selectorString='persist', extension='json', suffix='null'
org.apache.sling.api.scripting.ScriptEvaluationException:
                at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:388)
                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:533)
                at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:44)
                at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:77)
                at com.day.cq.personalization.impl.TargetComponentFilter.doFilter(TargetComponentFilter.java:96)
                at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:68)
                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:68)
              
               

 

Regards

Pr@veen