I was trying to convert vehicle routing solution object that has been processed by optaplanner solver to json string, but whenever I tried it, it keep prompt me this error:
Stack Trace:
com.fasterxml.jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError) (through reference chain: app.chameleon.marketing.salesman.routing.optimization.server.model.VehicleRoutingSolution["customerList"]->java.util.ArrayList[0]->app.chameleon.marketing.salesman.routing.optimization.client.model.Customer["nextCustomer"]->
...
app.chameleon.marketing.salesman.routing.optimization.client.model.Customer["previousStandstill"]) at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:653)
...
Caused by: java.lang.StackOverflowError
I have tried to use @JsonManagedReference and @JsonBackReference, but I can't figured it out how to use it. Since every time I used it, some members of Customer
class didn't converted to json (e.g. previousStandstill
or nextCustomer
).
If anyone experienced this issue, please share your solution. Any comments will be appreciated. Thank you.