Jackson mapper infinite incursion with sling models

shajiahmed

28-09-2020

when converting sling models to jackson mapper I am getting  java.lang.IllegalArgumentException: Infinite recursion (StackOverflowError) (through reference chain: ehi.author.ext.aem65.reporting.impl.reports.models.ReportPage["resource"]
 

ReportPage page = (ReportPage) report;

Map<String, Object> reportPagePropMap = objectMapper.convertValue(page, // failing here

new TypeReference<Map<String, Object>>() { 

});

Where ReportPage is a slingModel defined as 

@Model(adaptables=org.apache.sling.api.resource.Resource.class,defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)

public class ReportPage  {

@Self

private Resource resource;

Accepted Solutions (0)

Answers (1)

Answers (1)