Getting Error "org.apache.sling.api.request.RecursionTooDeepException" while using form options datasource options
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)


@joerghoh @arunpatidar @aanchal-sikka @vijayalakshmi_s @jeevanraj @harwinder-singh @anupampat
Please help me if you have any idea about this issue.

