Experience Fragment Path - org.apache.sling.api.request.RecursionTooDeepException error | Community
Skip to main content
June 29, 2022
Solved

Experience Fragment Path - org.apache.sling.api.request.RecursionTooDeepException error

  • June 29, 2022
  • 1 reply
  • 1629 views

Actually, I am not able to show the Experience Fragment through HTL from the Node Properties. When I include the below HTL in the HTML file, I am getting this error "org.apache.sling.api.request.RecursionTooDeepException:"

 

<div data-sly-test="${item.innerBannerType == 'with-badges'}" class="badge-wrapper position-relative"> <sly data-sly-resource="${item.fragmentPath}"></sly> </div>

 

But when I hard code the path like below, it's working

<sly data-sly-resource="${@path='/content/experience-fragments/we-retail/equipment/master', selectors='content', wcmmode='disabled'}"></sly>

 

Looking for a solution. 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 Shiv_Prakash_Patel

@shiv_prakash_patel 

It's not working. getting a different error.

"com.mysite.models.component.MyCustomComponent cannot be correctly instantiated by the Use API"

 

Any other way to solve this issue?


Hi @ameen_dev ,

Use this line of code :

<sly data-sly-resource="${@path=item.fragmentPath, selectors='content', wcmmode='disabled'}"></sly>

In place of below line of code in your sightly:

<sly data-sly-resource="${item.fragmentPath}"></sly>

Final sightly code should be like :

<div data-sly-test ="${item.innerBannerType == 'with-badges'}" class ="badge-wrapper position-relative">
<sly data-sly-resource="${@path=item.fragmentPath, selectors='content', wcmmode='disabled'}"></sly>
</div>

Please remove below line of code :

<sly data-sly-use.cmp="com.mysite.models.component.MyCustomComponent"></sly>

I think you have used the above section as well but MyCustomComponent Model class is not available in your codebase.

Instead of MyCustomComponent, you are using a different model class to get path that are stored in item and you are fetching as ${item.fragmentPath}.

1 reply

Shiv_Prakash_Patel
Community Advisor
Community Advisor
June 29, 2022

Hi @ameen_dev ,

Can you try as below :

<sly data-sly-use.cmp="com.mysite.models.component.MyCustomComponent"></sly>
<sly data-sly-resource="${@path=cmp.exPath, selectors='content', wcmmode='disabled'}"></sly>

https://sourcedcode.com/blog/aem/dynamically-include-an-experience-fragment-in-sightly 

Hope this could help you.

Regards ! 

Shiv Prakash
Ameen_DevAuthor
June 29, 2022

Where would I give this node property -> ${item.fragmentPath} in the above code?

Shiv_Prakash_Patel
Community Advisor
Community Advisor
June 29, 2022

In place of cmp.exPath :

<sly data-sly-resource="${@path=item.fragmentPath, selectors='content', wcmmode='disabled'}"></sly>
Shiv Prakash