Getting error in using POJO class with HTL code. | Community
Skip to main content
Level 3
Jan 7, 2021 12:36 PM UTC
Solved

Getting error in using POJO class with HTL code.

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.
Anudeep_Garnepudi
Anudeep_GarnepudiAccepted solution
New Participant
Feb 20, 2021 5:57 PM UTC

@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"

9 replies

Anudeep_Garnepudi
Anudeep_GarnepudiAccepted solution
New Participant
Feb 20, 2021 5:57 PM UTC

@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"

Translate
arunpatidar
New Participant
Jan 7, 2021 2:21 PM UTC

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.

Translate
Arun Patidar
Level 3
Jan 8, 2021 8:04 AM UTC
<div sly data-sly-use .demobeanObj="com.packagename.demoUse" data-sly-test="${demobeanObj}">
Translate
SureshDhulipudi
New Participant
Jan 7, 2021 1:00 PM UTC

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.

Translate
Level 3
Jan 8, 2021 8:07 AM UTC
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
Translate