title: gson.toJson() throws StackOverflowError in Servlet
body: <p>I have list of objects clients</p>
  
  <pre><code>List&lt;Client&gt; clientsList=new ArrayList&lt;Client&gt;();
  clientsList=clientDao.GetAllClients();
  </code></pre>
  
  <p>Entity Client has others list as attributes:</p>
  
  <pre><code>@ManyToOne(optional=false)
  private User createdBy;
  
  
  @ManyToMany(mappedBy = "Clients")
  private Set&lt;ClientType&gt; Types=new HashSet();
  
  
  @ManyToOne(optional=false)
  private LeadSource id_LeadSource;
  @ManyToOne(optional=false)
  private Agencie id_Agencie;
  
  @OneToMany(cascade=CascadeType.ALL,mappedBy="Owner")
  private Set&lt;Propertie&gt; properties=new HashSet();
  
  @OneToMany(cascade=CascadeType.ALL,mappedBy="buyer")
  private Set&lt;Sale&gt; sales=new HashSet();
  
  @OneToMany(cascade=CascadeType.ALL,mappedBy = "client")
  private Set&lt;Rent&gt; Rents=new HashSet();
  
  @OneToMany(cascade=CascadeType.ALL,mappedBy = "clientDoc")
  private Set&lt;Document&gt; Docuements=new HashSet();
  </code></pre>
  
  <p>and when i try to convert list of clients to json format</p>
  
  <pre><code>out.write(new Gson().toJson(clientsList));
  </code></pre>
  
  <p>i get this error :</p>
  
  <pre><code>java.lang.StackOverflowError
  at com.google.gson.stream.JsonWriter.beforeName(JsonWriter.java:603)
  at com.google.gson.stream.JsonWriter.writeDeferredName(JsonWriter.java:401)
  at com.google.gson.stream.JsonWriter.value(JsonWriter.java:512)
  at com.google.gson.internal.bind.TypeAdapters$8.write(TypeAdapters.java:270)
  at com.google.gson.internal.bind.TypeAdapters$8.write(TypeAdapters.java:255)
  at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:68)
  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:113)
  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:240)
  </code></pre>