Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Persisting CQ data in the Java Content Repository

Avatar

Level 2

hi, im following this tutorial:

http://helpx.adobe.com/adobe-cq/using/persisting-cq-data-java-content.html

i finished already, but my persist.json.jsp doesnt seem to resolve the CustomerService class created in the tutorial, here is the error log:

An error occurred at line: 8 in the jsp file: /apps/jcrpersist/components/page/templateJCR/persist.json.jsp com.adobe.cq.CustomerService cannot be resolved to a type 5: String phone = request.getParameter("phone"); 6: String desc = request.getParameter("desc"); 7: 8: com.adobe.cq.CustomerService cs = sling.getService(com.adobe.cq.CustomerService.class); 9: 10: int myPK = cs.injestCustData(first, last, phone, desc) ; 11:   

 

my bundle is active in the felix console, here it is:

[img]activeBundle.png[/img]

 

any idea how to fix this? or what am i missing?

1 Accepted Solution

Avatar

Correct answer by
Level 10

That is what happened -- in your Eclipse project -- make sure that you put the Java Customer Interface and Java class in the correct package - you need to place them in the same package as the com.adobe.cq.SimpleDSComponent.  You can delete the test package too. Its need required for this workflow. 

Then re-build your component using Maven and redeploy. Once you see the Customer service in the Service tab - you are good to go. You can invoke it from the JSP as shown in the article. 

View solution in original post

6 Replies

Avatar

Level 10

If you click on the Service tab -- do you see this data type listed under services? 

What version of CQ do you have? 

Avatar

Level 10

When looking at the services tab in the Felix Console - you should see this Java type: 

com.adobe.cq.CustomerService

as shown here:

[img]FelixBundleService.png[/img]

Let me know if you see this.

Avatar

Level 2

thanks for your response!

i dont see the type com.adobe.cq.CustomerService, all i see with customer is this:

[img]servicesTab.jpg[/img]

that is my bundle, com.adobe.cq.customer-bundle (315) it has the same id and if i click it it goes to my bundle (the image in my original post)

 

so that means mvn had an error compiling or something? because i dont see any errors in the log when i did the mvn clean install command 

my CQ version is: 5.6.1.20130606

 

thank you!

Avatar

Correct answer by
Level 10

That is what happened -- in your Eclipse project -- make sure that you put the Java Customer Interface and Java class in the correct package - you need to place them in the same package as the com.adobe.cq.SimpleDSComponent.  You can delete the test package too. Its need required for this workflow. 

Then re-build your component using Maven and redeploy. Once you see the Customer service in the Service tab - you are good to go. You can invoke it from the JSP as shown in the article. 

Avatar

Level 2

thanks!! that was it, i put the classes in the test package instead of the main.java package, i corrected the package and it works now!

thank you for your fast and helpful response! :)

Avatar

Level 1

Hello Smacdonald & Kornjjuan,

I have been trying to implement that above tutorial(http://helpx.adobe.com/experience-manager/using/persisting-cq-data-java-content1.html) very much and I dont know where I am missing. I just want to explain what I did, please bear with me..

1.Have cq 5.6.0, JDK 1.7, Maven 3.0.5 on my windows 7 (am I missing any setup? I am sure, I have added the Adobe Maven dependencies in the settings.xml)

2.Generated mvn bundle & content, next opened the Eclipse(just plain one, not m2e nothing), add the Interface & java class.

3.Got many import errors, Imported most of the libraries like

import org.apache.jackrabbit.commons.JcrUtils; import javax.jcr.RepositoryException; etc

4.After that created the required components in crxde lite, and after building the bundle, I got the service running in the felix console. But when ever I open the 

persist.json.jsp in the crxDE editor, it comes up with error Sling is not resolved at sling.getService(com.adobe.cq.CustomerService.class); line.

CC to Kornjjuan: Please share the package if you can, which was build successfully. 

Regards,

Sandeep.k

_________________________________________________________

 

Hello Scott, 

I have just made it working and its a perfect Tutorial, I am very new to  maven, and even Java & imports. So carefully sorted the resources and thus started working.

Many thanks for this kickoff implementation with JCR. Looking forward to learn more on this. If anyone( in similar to my sitation) and in need of the package, please mail me your req to sandeep.kantimahanthi@gmail.com

Regards,
Sandeepk