According to this article http://helpx.adobe.com/experience-manager/using/persisting-cq-data-java-content1.html# , finally run happened below error. I look into this problem for one day but no way to fix it.
Anyone could help see this problem, thanks in advance.
persist.json.jsp
<%@include file="/libs/foundation/global.jsp"%> <%@ page import="org.apache.sling.commons.json.io.*,com.adobe.cq.*" %><% String first = request.getParameter("first"); String last = request.getParameter("last"); String phone = request.getParameter("phone"); String desc = request.getParameter("desc");com.adobe.cq.CustomerService cs = sling.getService(com.adobe.cq.CustomerService.class);int myPK = cs.injestCustData(first, last, phone, desc) ; //Send the data back to the client JSONWriter writer = new JSONWriter(response.getWriter()); writer.object(); writer.key("pk"); writer.value(myPK); writer.endObject(); %>
Error message:
13.10.2014 11:16:45.677 *ERROR* [127.0.0.1 [1413170205545] GET /content/testjcr/_jcr_content.persist.json HTTP/1.1] org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught SlingException
org.apache.sling.scripting.jsp.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 8 in the jsp file: /apps/jcrpersist/components/page/templateJCR/persist.json.jspcom.adobe.cq.CustomerService cannot be resolved to a type5: 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: at org.apache.sling.scripting.jsp.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92) at org.apache.sling.scripting.jsp.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330) at org.apache.sling.scripting.jsp.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:421) at org.apache.sling.scripting.jsp.jasper.compiler.Compiler.compile(Compiler.java:312) at org.apache.sling.scripting.jsp.jasper.compiler.Compiler.compile(Compiler.java:290) at org.apache.sling.scripting.jsp.jasper.compiler.Compiler.compile(Compiler.java:277) at org.apache.sling.scripting.jsp.jasper.JspCompilationContext.compile(JspCompilationContext.java:501) at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.prepareServlet(JspServletWrapper.java:427) at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:486) 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)
OSGI bundle: