Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

AEM 6.2 Error

Avatar

Level 3

Hi,

We are using EP API's with AEM.

We have used below code in JSP

 

CommerceService commerceService = resource.adaptTo(CommerceService.class);
CommerceSession commerceSession = commerceService.login(slingRequest, slingResponse);    

 

It was working fine in AEM 6.0 but in After moving to AEM6.2 it is showing below error.

commerceSession cannot be resolved to a variable

Thanks,

Kumar.

5 Replies

Avatar

Employee

Hi,

Is the CommerceService class actually available in AEM? Check in the dependancy finder with the full class name: {HOST}/system/console/depfinder

I take it there is a an ElasticPath bundle you need to deploy? did you deploy the latest package for elastic path and AEM 6.2? Does the bundle start?

You really need to show the full error that you got in error.log

Regards,

Opkar

[0]https://docs.adobe.com/docs/en/aem/6-2/deploy/ecommerce/elasticpath.html

Avatar

Level 3

Hi,

Showing below ERROR.

*ERROR* [0:0:0:0:0:0:0:1 [1476202522242] GET /content/xyz/en_gb/product.M12534567.html HTTP/1.1] com.day.cq.wcm.tags.IncludeTag Error while executing script init.jsp
org.apache.sling.api.scripting.ScriptEvaluationException: An exception occurred processing JSP page /apps/projectname/components/page/productdetailpage/init.jsp at line 31
    at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:416)
    at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:184)
    at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:491)
    at com.day.cq.wcm.tags.IncludeTag.includeScript(IncludeTag.java:178)
    at com.day.cq.wcm.tags.IncludeTag.doEndTag(IncludeTag.java:95)
    at org.apache.jsp.apps.projectname.components.page.projectnamebasepage.projectnamebasepage_jsp._jspx_meth_cq_005finclude_005f0(projectnamebasepage_jsp.java:334)
    at org.apache.jsp.apps.projectname.components.page.projectnamebasepage.projectnamebasepage_jsp._jspService(projectnamebasepage_jsp.java:177)
    at org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:502)
    at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:449)
    at org.apache.sling.scripting.jsp.JspScriptEngineFactory.callJsp(JspScriptEngineFactory.java:284)
    at org.apache.sling.scripting.jsp.JspScriptEngineFactory.access$100(JspScriptEngineFactory.java:102)
    at org.apache.sling.scripting.jsp.JspScriptEngineFactory$JspScriptEngine.eval(JspScriptEngineFactory.java:536)
    at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:388)
    at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:184)
    at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:491)
    at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:546)
    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:187)
    at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilter(WCMDebugFilter.java:154)
    at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:68)
    at com.day.cq.wcm.core.impl.WCMComponentFilter.doFilter(WCMComponentFilter.java:265)
    at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:68)
    at com.day.cq.wcm.core.impl.WCMDeveloperModeFilter.doFilter(WCMDeveloperModeFilter.java:114)
    at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:68)
    at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:282)
    at org.apache.sling.engine.impl.SlingRequestProcessorImpl.dispatchRequest(SlingRequestProcessorImpl.java:322)
    at org.apache.sling.engine.impl.request.SlingRequestDispatcher.dispatch(SlingRequestDispatcher.java:211)
    at org.apache.sling.engine.impl.request.SlingRequestDispatcher.include(SlingRequestDispatcher.java:104)
    at com.day.cq.wcm.core.impl.WCMComponentFilter$ForwardRequestDispatcher.include(WCMComponentFilter.java:503)
    at org.apache.jsp.libs.cq.Page.Page_jsp._jspService(Page_jsp.java:106)

 

In JSP file we have used.

 CommerceService commerceService = resource.adaptTo(CommerceService.class);
 CommerceSession commerceSession = commerceService.login(slingRequest, slingResponse);    

 

In AEM6.0 It was working properly. Showing errors in AEM6.2

 

Thanks,

Avatar

Level 3

Hi,

@Opkar

Added Elastic path bundles and the status of the bundles are active state.

Still showing below Error.

*ERROR* [127.0.0.1 [1476345714841] GET /content/xyz/en_id/product.1234567893X.html HTTP/1.1] org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught SlingException
java.lang.Error: Unresolved compilation problem: 
    The type com.elasticpath.aem.commerce.ElasticPathCommerceSession cannot be resolved. It is indirectly referenced from required .class files

    at org.apache.jsp.apps.projectname.components.page.productdetailpage.init_jsp.<init>(init_jsp.java:1)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.loadServlet(JspServletWrapper.java:165)
    at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.prepareServlet(JspServletWrapper.java:434)
    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:284)
    at org.apache.sling.scripting.jsp.JspScriptEngineFactory.access$100(JspScriptEngineFactory.java:102)
    at org.apache.sling.scripting.jsp.JspScriptEngineFactory$JspScriptEngine.eval(JspScriptEngineFactory.java:536)
    at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:388)
    at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:184)
    at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:491)
    at com.day.cq.wcm.tags.IncludeTag.includeScript(IncludeTag.java:178)
    at com.day.cq.wcm.tags.IncludeTag.doEndTag(IncludeTag.java:95)

Thanks