# Jersey : zirkulärer Aufruf



## jemand (12. Jan 2016)

Hallo liebe Developer ),
habe hier eine Dto-Klasse, die ich mit Jersey in ein JSON-String mappen möchte ...


```
package dtos;
import java.util.ArrayList;
import java.util.List;
import org.codehaus.jackson.annotate.JsonBackReference;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonManagedReference;
public class PersonDto extends NativePersonDto {
   
  private PersonDto partner;
  private PersonDto mother;
  private PersonDto father;
  private List<PersonDto> childrens = new ArrayList<PersonDto>();
  public void setPartner(PersonDto partner) {
  this.partner = partner;
  }
   
  public PersonDto getPartner() {
  return partner;
  }
   
  //@JsonBackReference
  public PersonDto getMother() {
  return mother;
  }
   
  //@JsonBackReference
  public void setMother(PersonDto mother) {
  this.mother = mother;
  }
   
  //@JsonBackReference
  public PersonDto getFather() {
  return father;
  }
   
  //@JsonBackReference
  public void setFather(PersonDto father) {
  this.father = father;
  }
  @JsonManagedReference
  @JsonBackReference
  public void setChildrens(List<PersonDto> childrens) {
  this.childrens = childrens;
  }
   
  @JsonManagedReference
  @JsonBackReference
  public List<PersonDto> getChildrens() {
  return childrens;
  }
}
```
Um das bidirektionale Mapping für diese Klasse in Jersey zu testen, habe ich folgenden Test aufgestellt.

```
private PersonDto createPersonDto_WithBiMapping() {
  PersonDto personDto = new PersonDto();
  personDto.setId(1L);
   
  PersonDto mother = new PersonDto();
  mother.setId(2L);
  mother.getChildrens().add(personDto);
   
  personDto.setMother(mother);
   
  PersonDto father = new PersonDto();
  father.setId(3L);
  father.getChildrens().add(personDto);
   
  personDto.setFather(father);
   
  PersonDto child1 = new PersonDto();
  personDto.getChildrens().add(child1);
  return personDto;
  }
```
Weiß einer, wie man Jersey das bidirektionale Mapping für diese Klasse beibringen kann?
Z.Z. kommt folgende Exception, sobald ich diesen Test ausführe ...

```
org.codehaus.jackson.map.JsonMappingException: Infinite recursion (StackOverflowError) (through reference chain: dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"]->java.util.ArrayList[0]->dtos.PersonDto["mother"]->dtos.PersonDto["childrens"])
  at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:189)
  at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:142)
  at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:430)
  at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:175)
  at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:142)
  at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:304)
  at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:254)
  at org.codehaus.jackson.map.ser.ContainerSerializers$AsArraySerializer.serialize(ContainerSerializers.java:142)
  at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:430)
  at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:175)
  at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:142)
  at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:430)
  at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:175)
  at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:142)
  at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:304)
  at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:254)
  at org.codehaus.jackson.map.ser.ContainerSerializers$AsArraySerializer.serialize(ContainerSerializers.java:142)
  at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:430)
  at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:175)
  at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:142)
  at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:430)
  at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:175)
  at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:142)
  at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:304)
  at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:254)
  at org.codehaus.jackson.map.ser.ContainerSerializers$AsArraySerializer.serialize(ContainerSerializers.java:142)
  at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:430)
  at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:175)
  at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:142)
  at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:430)
  at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:175)
  at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:142)
  at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:304)
  at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:254)
  at org.codehaus.jackson.map.ser.ContainerSerializers$AsArraySerializer.serialize(ContainerSerializers.java:142)
  at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:430)
  at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:175)
  at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:142)
  at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:430)
  at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:175)
  at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:142)
  at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:304)
  at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:254)
  at org.codehaus.jackson.map.ser.ContainerSerializers$AsArraySerializer.serialize(ContainerSerializers.java:142)
  at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:430)
  at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:175)
  at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:142)
  at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:430)
  at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:175)
  at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:142)
  at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:304)
  at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:254)
  at org.codehaus.jackson.map.ser.ContainerSerializers$AsArraySerializer.serialize(ContainerSerializers.java:142)
  at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:430)
  at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:175)
  at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:142)
  at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:430)
  at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:175)
  at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:142)
  at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:304)
  at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:254)
  at org.codehaus.jackson.map.ser.ContainerSerializers$AsArraySerializer.serialize(ContainerSerializers.java:142)
  at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:430)
  at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:175)
  at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:142)
  at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:430)
  at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:175)
  at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:142)
  at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:304)
  at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:254)
  at org.codehaus.jackson.map.ser.ContainerSerializers$AsArraySerializer.serialize(ContainerSerializers.java:142)
  at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:430)
  at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:175)
  at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:142)
```

Ich hab's, wie auf folgender Seite beschrieben, hauptsächlich mit JsonManagedReference/JsonBackReference/JsonIdentityInfo versucht, allerdings bleibt diese Exception ...

http://www.baeldung.com/jackson-bidirectional-relationships-and-infinite-recursion


----------



## jemand (12. Jan 2016)

Oder weiß einer, wie man JsonIgnore etc. richtig anwenden kann, wenn wie hier in meiner Dto-Klasse dargestellt, Haupt-Dto/Partner/Childs etc. alles das gleiche Dto ist? Wenn ich hier z.B. bei meinen Childs JsonIgnore dranschreiben würde, würden meine Childrens komplett ignoriert werden ... Wenn meine Childs allerdings ein eigenes Dto (nicht PersonDto, sondern z.B. ChildDto) wäre, hätte ich bei der ChildDto durch JsonIgnore ein StackOverflow verhindern können, aber alles, egal ob Child oder Parent soll auf PersonDto setzen.


----------



## Joose (12. Jan 2016)

Das Problem ist das nicht jede Format dafür geeignet ist zirkuläre Referenzen abzubilden.
In deinem Fall würde ich einfach bei dem "children" (ohne 's' da es ja schon die Mehrzahl ist ) die @JsonIgnore Annotation hinzufügen.
Durch die Referenzen von "mother" und "father" hast du indirekt auch die Kindbeziehungen abgebildet. Anders rum wäre dies nicht möglich.

Du könntest dir auch deinen eigenen JsonSerializer schreiben, welche sich merkt (anhand einer Id oder ähnlichen) welche Objekte er schon serialisiert hat und diese dann auslässt).


----------



## jemand (13. Jan 2016)

Joose:
Danke )


----------

