Jackson mapper infinite incursion with sling models

Avatar

Avatar
Give Back 5
Level 2
shajiahmed
Level 2

Likes

5 likes

Total Posts

54 posts

Correct reply

3 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 5
Ignite 3
View profile

Avatar
Give Back 5
Level 2
shajiahmed
Level 2

Likes

5 likes

Total Posts

54 posts

Correct reply

3 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 5
Ignite 3
View profile
shajiahmed
Level 2

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)

Avatar

Avatar
Contributor
Level 2
VeenaK
Level 2

Likes

18 likes

Total Posts

15 posts

Correct reply

3 solutions
Top badges earned
Contributor
Shape 1
Give Back
Boost 5
Boost 3
View profile

Avatar
Contributor
Level 2
VeenaK
Level 2

Likes

18 likes

Total Posts

15 posts

Correct reply

3 solutions
Top badges earned
Contributor
Shape 1
Give Back
Boost 5
Boost 3
View profile
VeenaK
Level 2

09-10-2020

Can you provide more info exactly you want to do in the model class?

 

Sample Code or Logic that you want to achieve?

 

Thanks,

Veena K