Expand my Community achievements bar.

Getting Error "org.apache.sling.api.request.RecursionTooDeepException" while using form options datasource options

Avatar

Level 2

Hi All, can you please help me resolve this issue which I am encountering with form options datasource options.


18.03.2024 21:51:43.345 *INFO* [oak-repository-executor-1] com.adobe.granite.repository Service [9609, [org.apache.jackrabbit.oak.api.jmx.SessionMBean]] ServiceEvent REGISTERED
18.03.2024 21:51:43.399 *ERROR* [[0:0:0:0:0:0:0:1] [1710778568716] GET /content/my-project/sg/en/testcaptcha.html HTTP/1.1] com.adobe.cq.wcm.core.components.internal.models.v1.form.OptionsImpl Failed to include the datasource at captcha/datasource/site-name
org.apache.sling.api.request.RecursionTooDeepException: /content/my-project/sg/en/testcaptcha/jcr:content/root/responsivegrid/container/options
at org.apache.sling.engine.impl.request.RequestData.setContent(RequestData.java:611) [org.apache.sling.engine:2.7.10.B0004]
at org.apache.sling.engine.impl.SlingRequestProcessorImpl.dispatchRequest(SlingRequestProcessorImpl.java:312) [org.apache.sling.engine:2.7.10.B0004]
at org.apache.sling.engine.impl.request.SlingRequestDispatcher.dispatch(SlingRequestDispatcher.java:211) [org.apache.sling.engine:2.7.10.B0004]
at org.apache.sling.engine.impl.request.SlingRequestDispatcher.include(SlingRequestDispatcher.java:104) [org.apache.sling.engine:2.7.10.B0004]

package com.myproject.commons.core.models.form;

import com.adobe.cq.wcm.core.components.models.form.Options;
import org.osgi.annotation.versioning.ProviderType;

import java.util.List;

@ProviderType
public interface FormOptions extends Options {

boolean isRequired();

String getRequiredMessage();

String getSource();

List<Object> getProperties();

}
package com.myproject.commons.core.models.form;

import com.adobe.cq.export.json.ComponentExporter;
import com.adobe.cq.export.json.ExporterConstants;
import com.adobe.cq.wcm.core.components.models.form.OptionItem;
import com.adobe.cq.wcm.core.components.models.form.Options;
import com.capitaland.commons.core.bean.form.FormOptionsBean;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.*;
import org.apache.sling.models.annotations.injectorspecific.ChildResource;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.Self;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.apache.sling.models.annotations.via.ResourceSuperType;
import org.jetbrains.annotations.NotNull;

import javax.inject.Named;
import java.util.ArrayList;
import java.util.List;

@Model(
adaptables = SlingHttpServletRequest.class,
adapters = {FormOptions.class, ComponentExporter.class},
resourceType = FormOptionsImpl.RESOURCE_TYPE,
defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class FormOptionsImpl implements FormOptions {

private static final String PROP_REQUIRED_MESSAGE_DEFAULT = "";
private static final boolean PROP_REQUIRED_DEFAULT = false;
private static final String ID_PREFIX = "form-options";
static final String RESOURCE_TYPE = "my-project/components/form/options/v2-0/options";

@Self
@Via(type = ResourceSuperType.class)
private Options options;

@ChildResource(
injectionStrategy = InjectionStrategy.OPTIONAL
)
@Named("items")
private List<Resource> itemsResource;

@ValueMapValue
@Default(booleanValues = PROP_REQUIRED_DEFAULT)
@Getter
private boolean required;

@ValueMapValue
@Default(values = PROP_REQUIRED_MESSAGE_DEFAULT)
@Getter
private String requiredMessage;

@ValueMapValue
@Getter
private String source;

@Override
public List getProperties() {
if ("local".equals(source)) {
List<FormOptionsBean> propertiesList = new ArrayList<>();
for (Resource resource : itemsResource) {
if (resource != null) {
FormOptionsBean optionsBean = new FormOptionsBean();
resource.getValueMap().forEach((key, value) -> {
switch (key) {
case "selected":
optionsBean.setSelected(Boolean.parseBoolean((String) value));
break;
case "disabled":
optionsBean.setDisabled(Boolean.parseBoolean((String) value));
break;
case "text":
optionsBean.setText((String) value);
break;
case "value":
optionsBean.setValue((String) value);
break;
case "experienceFragment":
if (value != null) {
optionsBean.setExperienceFragment((String) value);
} else {
optionsBean.setExperienceFragment(StringUtils.EMPTY);
}
break;
default:
break;
}
});
propertiesList.add(optionsBean);
}
}
return propertiesList;
} else {
return this.getItems();
}
}

@Override
@NotNull
public String getExportedType() {
return options.getExportedType();
}

// methods of OptionsImpl
@Override
public List<OptionItem> getItems() {
return options.getItems();
}

@Override
public String getHelpMessage() {
return options.getHelpMessage();
}

@Override
public Type getType() {
return options.getType();
}

protected String getIDPrefix() {
return ID_PREFIX;
}

@Override
public String getValue() {
return getDefaultValue();
}

protected String getDefaultName() {
return null;
}

protected String getDefaultValue() {
return null;
}

protected String getDefaultTitle() {
return null;
}

@Override
public String getId() {
return options.getId();
}

@Override
public String getName() {
return options.getName();
}

@Override
public String getTitle() {
return options.getTitle();
}

}



Adding a simple htl to just print the no of datasource items for datasource (core/wcm/components/form/container/v1/datasource/actiontype)

 

MaheshMR28_0-1710830144661.png

MaheshMR28_1-1710830193003.png

 

 



@joerghoh @arunpatidar  @aanchal-sikka  @Vijayalakshmi_S @JeevanRaj @Harwinder-singh  @anupampat 
Please help me if you have any idea about this issue.

13 Replies

Avatar

Community Advisor

@MaheshMR28 Can you share your HTL code as well just to see if there is anything that we can spot there?

Avatar

Level 2

@Harwinder-singh , thanks for looking into the issue, I am attaching the component here. 

Avatar

Level 4

Hi @MaheshMR28 ,

 

Please check https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/recursiontoodeepexception-...

Can you include resourceType at two places for 

<div data-sly-resource in your HTL code in - options.html

Avatar

Level 2

@anupampat , Can you please help me add in this HTL?


 

<sly data-sly-use.options="com.myproject.commons.core.models.form.FormOptionsImpl"
     data-sly-use.template="core/wcm/components/commons/v1/templates.html"
     data-sly-test.isNotEmpty="${options.items.size}">
	<p>${options.items.size}</p>
</sly>
<sly data-sly-call="${template.placeholder @ isEmpty=!isNotEmpty, classAppend='cmp-form-options'}"></sly>

 

Avatar

Community Advisor

Hi @MaheshMR28 

 

In situations where a node is not exists, AEM attempts to locate that node recursively, which is a behavior stemming from an internal product bug. To address this issue, I recommend verifying the existence of the "captcha/datasource/site-name" node.

Could you please specify the version of AEM you are currently using?



Arun Patidar

Avatar

Level 2

Hi @arunpatidar , 

captcha/datasource/site-name is a custom datasource defined in the project, if I use the predefined datasource core/wcm/components/form/container/v1/datasource/actiontype , I still get the same error. I feel something is missed in the java code.

I am using the AEM version 6.5.16/6.5.19

Avatar

Community Advisor

Hi @MaheshMR28 
What version of core components are using?



Arun Patidar

Avatar

Level 2

I already check it. The issue is not resolved nor any suggestions on that topic. 

Avatar

Administrator

@MaheshMR28 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni

Avatar

Level 2

Hi @kautuk_sahni , none of the solutions worked so far, trying out to fix this issue. I'll update, if I find any and mark solved.