Json serialization errors caused by json serialization loop reference
The following error message is displayed:
Caused by: java. lang. IllegalStateException: circular reference error
Offending field: methodAccessor
Offending object: preserveType: false, type: interface sun. reflect. MethodAccessor, obj: sun. reflect. DelegatingMethodAccessorImpl @ 5886f7bf
At com. google. gson. CircularReferenceException. createDetailedException (CircularReferenceException. java: 43)
At com. google. gson. JsonSerializationVisitor. visitObjectField (JsonSerializationVisitor. java: 115)
At com. google. gson. ObjectNavigator. navigateClassFields (ObjectNavigator. java: 164)
At com. google. gson. ObjectNavigator. accept (ObjectNavigator. java: 131)
At com. google. gson. JsonSerializationVisitor. getJsonElementForChild (JsonSerializationVisitor. java: 147)
At com. google. gson. JsonSerializationVisitor. addAsChildOfObject (JsonSerializationVisitor. java: 125)
At com. google. gson. JsonSerializationVisitor. visitObjectField (JsonSerializationVisitor. java: 112)
At com. google. gson. ObjectNavigator. navigateClassFields (ObjectNavigator. java: 164)
At com. google. gson. ObjectNavigator. accept (ObjectNavigator. java: 131)
At com. google. gson. JsonSerializationVisitor. getJsonElementForChild (JsonSerializationVisitor. java: 147)
At com. google. gson. JsonSerializationVisitor. addAsChildOfObject (JsonSerializationVisitor. java: 125)
At com. google. gson. JsonSerializationVisitor. visitObjectField (JsonSerializationVisitor. java: 112)
At com. google. gson. ObjectNavigator. navigateClassFields (ObjectNavigator. java: 164)
At com. google. gson. ObjectNavigator. accept (ObjectNavigator. java: 131)
At com. google. gson. JsonSerializationVisitor. getJsonElementForChild (JsonSerializationVisitor. java: 147)
At com. google. gson. JsonSerializationVisitor. addAsChildOfObject (JsonSerializationVisitor. java: 125)
At com. google. gson. JsonSerializationVisitor. visitObjectField (JsonSerializationVisitor. java: 112)
At com. google. gson. ObjectNavigator. navigateClassFields (ObjectNavigator. java: 164)
At com. google. gson. ObjectNavigator. accept (ObjectNavigator. java: 131)
At com. google. gson. JsonSerializationVisitor. getJsonElementForChild (JsonSerializationVisitor. java: 147)
At com. google. gson. JsonSerializationVisitor. addAsChildOfObject (JsonSerializationVisitor. java: 125)
At com. google. gson. JsonSerializationVisitor. visitObjectField (JsonSerializationVisitor. java: 112)
At com. google. gson. ObjectNavigator. navigateClassFields (ObjectNavigator. java: 164)
At com. google. gson. ObjectNavigator. accept (ObjectNavigator. java: 131)
At com. google. gson. JsonSerializationVisitor. getJsonElementForChild (JsonSerializationVisitor. java: 147)
At com. google. gson. JsonSerializationVisitor. addAsChildOfObject (JsonSerializationVisitor. java: 125)
At com. google. gson. JsonSerializationVisitor. visitObjectField (JsonSerializationVisitor. java: 112)
At com. google. gson. ObjectNavigator. navigateClassFields (ObjectNavigator. java: 164)
At com. google. gson. ObjectNavigator. accept (ObjectNavigator. java: 131)
At com. google. gson. JsonSerializationVisitor. getJsonElementForChild (JsonSerializationVisitor. java: 147)
At com. google. gson. JsonSerializationVisitor. addAsChildOfObject (JsonSerializationVisitor. java: 125)
At com. google. gson. JsonSerializationVisitor. visitObjectField (JsonSerializationVisitor. java: 112)
At com. google. gson. ObjectNavigator. navigateClassFields (ObjectNavigator. java: 164)
At com. google. gson. ObjectNavigator. accept (ObjectNavigator. java: 131)
At com. google. gson. JsonSerializationVisitor. getJsonElementForChild (JsonSerializationVisitor. java: 147)
At com. google. gson. JsonSerializationVisitor. addAsChildOfObject (JsonSerializationVisitor. java: 125)
At com. google. gson. JsonSerializationVisitor. visitObjectField (JsonSerializationVisitor. java: 112)
At com. google. gson. ObjectNavigator. navigateClassFields (ObjectNavigator. java: 164)
At com. google. gson. ObjectNavigator. accept (ObjectNavigator. java: 131)
At com. google. gson. JsonSerializationContextDefault. serialize (JsonSerializationContextDefault. java: 56)
At com. google. gson. Gson. toJsonTree (Gson. java: 233)
At com. google. gson. Gson. toJson (Gson. java: 273)
At com. google. gson. Gson. toJson (Gson. java: 253)
At com. htsoft. oa. action. structuringdatamanage. TableargAction. get (TableargAction. java: 142)
At sun. reflect. NativeMethodAccessorImpl. invoke0 (Native Method)
At sun. reflect. NativeMethodAccessorImpl. invoke (NativeMethodAccessorImpl. java: 57)
At sun. reflect. DelegatingMethodAccessorImpl. invoke (DelegatingMethodAccessorImpl. java: 43)
At java. lang. reflect. Method. invoke (Method. java: 606)
At com. opensymphony. xwork2.defaactionactioninvocation. invokeAction (DefaultActionInvocation. java: 404)
At com. opensymphony. xwork2.DefaultActionInvocation. invokeActionOnly (DefaultActionInvocation. java: 267)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 229)
At com. opensymphony. xwork2.interceptor. DefaultWorkflowInterceptor. doIntercept (defaworkworkflowinterceptor. java: 221)
At com. opensymphony. xwork2.interceptor. MethodFilterInterceptor. intercept (MethodFilterInterceptor. java: 86)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 224)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 223)
At com. opensymphony. xwork2.util. profiling. UtilTimerStack. profile (UtilTimerStack. java: 455)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221)
At com. opensymphony. xwork2.validator. ValidationInterceptor. doIntercept (ValidationInterceptor. java: 150)
At org. apache. struts2.interceptor. validation. AnnotationValidationInterceptor. doIntercept (AnnotationValidationInterceptor. java: 48)
At com. opensymphony. xwork2.interceptor. MethodFilterInterceptor. intercept (MethodFilterInterceptor. java: 86)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 224)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 223)
At com. opensymphony. xwork2.util. profiling. UtilTimerStack. profile (UtilTimerStack. java: 455)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221)
At com. opensymphony. xwork2.interceptor. ConversionErrorInterceptor. intercept (ConversionErrorInterceptor. java: 123)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 224)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 223)
At com. opensymphony. xwork2.util. profiling. UtilTimerStack. profile (UtilTimerStack. java: 455)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221)
At com. opensymphony. xwork2.interceptor. ParametersInterceptor. doIntercept (ParametersInterceptor. java: 184)
At com. opensymphony. xwork2.interceptor. MethodFilterInterceptor. intercept (MethodFilterInterceptor. java: 86)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 224)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 223)
At com. opensymphony. xwork2.util. profiling. UtilTimerStack. profile (UtilTimerStack. java: 455)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221)
At com. opensymphony. xwork2.interceptor. StaticParametersInterceptor. intercept (StaticParametersInterceptor. java: 105)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 224)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 223)
At com. opensymphony. xwork2.util. profiling. UtilTimerStack. profile (UtilTimerStack. java: 455)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221)
At org. apache. struts2.interceptor. CheckboxInterceptor. intercept (CheckboxInterceptor. java: 83)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 224)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 223)
At com. opensymphony. xwork2.util. profiling. UtilTimerStack. profile (UtilTimerStack. java: 455)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221)
At org. apache. struts2.interceptor. FileUploadInterceptor. intercept (FileUploadInterceptor. java: 207)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 224)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 223)
At com. opensymphony. xwork2.util. profiling. UtilTimerStack. profile (UtilTimerStack. java: 455)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221)
At com. opensymphony. xwork2.interceptor. ModelDrivenInterceptor. intercept (ModelDrivenInterceptor. java: 74)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 224)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 223)
At com. opensymphony. xwork2.util. profiling. UtilTimerStack. profile (UtilTimerStack. java: 455)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221)
At com. opensymphony. xwork2.interceptor. ScopedModelDrivenInterceptor. intercept (ScopedModelDrivenInterceptor. java: 127)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 224)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 223)
At com. opensymphony. xwork2.util. profiling. UtilTimerStack. profile (UtilTimerStack. java: 455)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221)
At org. apache. struts2.interceptor. ProfilingActivationInterceptor. intercept (ProfilingActivationInterceptor. java: 107)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 224)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 223)
At com. opensymphony. xwork2.util. profiling. UtilTimerStack. profile (UtilTimerStack. java: 455)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221)
At org. apache. struts2.interceptor. debugging. DebuggingInterceptor. intercept (DebuggingInterceptor. java: 206)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 224)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 223)
At com. opensymphony. xwork2.util. profiling. UtilTimerStack. profile (UtilTimerStack. java: 455)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221)
At com. opensymphony. xwork2.interceptor. ChainingInterceptor. intercept (ChainingInterceptor. java: 115)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 224)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 223)
At com. opensymphony. xwork2.util. profiling. UtilTimerStack. profile (UtilTimerStack. java: 455)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221)
At com. opensymphony. xwork2.interceptor. I18nInterceptor. intercept (I18nInterceptor. java: 143)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 224)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 223)
At com. opensymphony. xwork2.util. profiling. UtilTimerStack. profile (UtilTimerStack. java: 455)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221)
At com. opensymphony. xwork2.interceptor. PrepareInterceptor. doIntercept (PrepareInterceptor. java: 121)
At com. opensymphony. xwork2.interceptor. MethodFilterInterceptor. intercept (MethodFilterInterceptor. java: 86)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 224)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 223)
At com. opensymphony. xwork2.util. profiling. UtilTimerStack. profile (UtilTimerStack. java: 455)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221)
At org. apache. struts2.interceptor. ServletConfigInterceptor. intercept (ServletConfigInterceptor. java: 170)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 224)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 223)
At com. opensymphony. xwork2.util. profiling. UtilTimerStack. profile (UtilTimerStack. java: 455)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221)
At com. opensymphony. xwork2.interceptor. AliasInterceptor. intercept (AliasInterceptor. java: 123)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 224)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 223)
At com. opensymphony. xwork2.util. profiling. UtilTimerStack. profile (UtilTimerStack. java: 455)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221)
At com. opensymphony. xwork2.interceptor. ExceptionMappingInterceptor. intercept (ExceptionMappingInterceptor. java: 176)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 224)
At com. opensymphony. xwork2.DefaultActionInvocation $2. doProfiling (DefaultActionInvocation. java: 223)
At com. opensymphony. xwork2.util. profiling. UtilTimerStack. profile (UtilTimerStack. java: 455)
At com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 221)
At org.apache.struts2.impl.StrutsActionProxy.exe cute (StrutsActionProxy. java: 50)
At org. apache. struts2.dispatcher. Dispatcher. serviceAction (Dispatcher. java: 504)
... 68 more
Solution:
You can also use transient to modify attributes with cyclic references. For example:
Private transient Dbarg dbarg;