I was facing an issue while converting a bean with request scope to JSON using object mapper. It thows an exception like below. Not sure what am missing. I couldn't find any relatable resource on the web. Can someone explain what should be the way to do this.
Thanks in advance.
Line of code :
planInfo -> Bean with request scope
String json = new ObjectMapper().writeValueAsString(planInfo);
Exception :
"timestampSeconds":1630567890,"timestampNanos":683000000,"severity":"ERROR","thread":"qtp133294616-216","logger":"com.signup.api.service.SignupService","message":"exception \ncom.fasterxml.jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError) (through reference chain: jdk.internal.loader.ClassLoaders$PlatformClassLoader[\"unnamedModule\"]-\u003ejava.lang.Module[\"classLoader\"]-....
PlanInfo
import lombok.Data;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
@Data
@Component
@RequestScope
public class PlanInfo {
String additionalPlanDetails;
String additionalServiceCost;
String listOfAdditionalServiceIds;
String planMinutes;
String planPrice;
String totalamt;
String setUpFee;
String selectedPlanId;
String canadaProvince;
String vatAmount;
String vatPercentage;
String netTotalAmt;
String selectedIvrPlanId;
String selectedIvrPlanMinutes;
String selectedIvrPlanPrice;
String totalPlanPrice;
String totalAmtAfterDiscount;
boolean waiveSetupFee;
String planCategory;
}