Getting error in using POJO class with HTL code. | Community
Skip to main content
Level 3
January 7, 2021
Solved

Getting error in using POJO class with HTL code.

  • January 7, 2021
  • 3 replies
  • 2771 views

I was trying to take dialog values from AEM component and then map it to POJO class to retrieve data from POJO class but getting error:

org.apache.sling.api.slingexception: Cannot get DefaultSlingScript: No use provider could resolve identifier ....... 

Please help.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Anudeep_Garnepudi

@shagunmalik 

Package and Class names that referred  in HTL are case sensitive.

If your Use class fully qualified name is com.yourpackage.DemoUse then your HTL file should be like

<sly data-sly-use.demoUse="com.yourpackage.DemoUse"> .... </sly>

You are referring as data-sly-use.demoUse="com.yourpackage.demoUse"

3 replies

SureshDhulipudi
Community Advisor
Community Advisor
January 7, 2021

Can you provide your POJO class?

If you are using Sling Model, use the correct annotations and give the DEFAULT strategy options.

If any one of the node/property is null / empty, you will see this error.

Level 3
January 8, 2021
package com.community.aem.core; /** * The Class HeroTextBean. */ public class HeroTextBean { /** The heading text. */ private String headingText; /** The description. */ private String description; /** * @2007960 the headingText */ public String getHeadingText() { return headingText; } /** * @90521 headingText the headingText to set */ public void setHeadingText(String headingText) { this.headingText = headingText; } /** * @2007960 the description */ public String getDescription() { return description; } /** * @90521 description the description to set */ public void setDescription(String description) { this.description = description; } } This is the code I used of help.adobe for creating my code
arunpatidar
Community Advisor
Community Advisor
January 7, 2021

The issue could be with HTL data-sly-use statement. data-sly-use can only have Model/WCMUsePojo type

e.g. https://github.com/arunpatidar02/aem63app-repo/blob/master/java/ClientLibsModel.java

https://github.com/arunpatidar02/aem63app-repo/blob/master/java/DisableEditModel.java

 

If you will just call POJO from htl, then it will not work.

Arun Patidar
Level 3
January 8, 2021
<div sly data-sly-use .demobeanObj="com.packagename.demoUse" data-sly-test="${demobeanObj}">
Anudeep_Garnepudi
Community Advisor
Anudeep_GarnepudiCommunity AdvisorAccepted solution
Community Advisor
February 20, 2021

@shagunmalik 

Package and Class names that referred  in HTL are case sensitive.

If your Use class fully qualified name is com.yourpackage.DemoUse then your HTL file should be like

<sly data-sly-use.demoUse="com.yourpackage.DemoUse"> .... </sly>

You are referring as data-sly-use.demoUse="com.yourpackage.demoUse"

AG