title: Play! Framework sample list render with JQuery
body: <p>need some help, i have a server-side Contoller function:</p>
  
  <pre><code>public static void getNews(){
      List&lt;Thread&gt; threads = Thread.findAll();
      renderJSON(threads);
  }
  </code></pre>
  
  <p>And front-end request: </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $.getJSON('@{Application.getNews()}', function(threads) {
        var items = [];
  
        $.each(threads, function(title, text) {
          items.push("&lt;div&gt;" + text + "&lt;/div&gt;");
        });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>But it doesn't work. Console exception listing:</p>
  
  <pre><code>Internal Server Error (500) for request GET /application/getnews
  
  Execution exception (In /app/controllers/Application.java around line 43)
  IllegalStateException occured : circular reference error   Offending field: thre
  ads    Offending object: preserveType: true, type: class models.Thread, obj: Thr
  ead[21]
  
  play.exceptions.JavaExecutionException: circular reference error
    Offending field: threads
  
    Offending object: preserveType: true, type: class models.Thread, obj: Thread[2
  1]
          at play.mvc.ActionInvoker.invoke(ActionInvoker.java:227)
          at Invocation.HTTP Request(Play!)
  Caused by: java.lang.IllegalStateException: circular reference error
    Offending field: threads
  
    Offending object: preserveType: true, type: class models.Thread, obj: Thread[2
  1]
          at com.google.gson.CircularReferenceException.createDetailedException(Ci
  rcularReferenceException.java:43)
          at com.google.gson.JsonSerializationVisitor.visitFieldUsingCustomHandler
  (JsonSerializationVisitor.java:212)
          at com.google.gson.ObjectNavigator.navigateClassFields(ObjectNavigator.j
  ava:158)
          at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:131)
          at com.google.gson.JsonSerializationVisitor.getJsonElementForChild(JsonS
  erializationVisitor.java:147)
          at com.google.gson.JsonSerializationVisitor.addAsChildOfObject(JsonSeria
  lizationVisitor.java:125)
          at com.google.gson.JsonSerializationVisitor.visitObjectField(JsonSeriali
  zationVisitor.java:112)
          at com.google.gson.ObjectNavigator.navigateClassFields(ObjectNavigator.j
  ava:164)
          at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:131)
          at com.google.gson.JsonSerializationContextDefault.serialize(JsonSeriali
  zationContextDefault.java:56)
          at com.google.gson.JsonSerializationContextDefault.serialize(JsonSeriali
  zationContextDefault.java:49)
          at com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter.serialize(D
  efaultTypeAdapters.java:528)
          at com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter.serialize(D
  efaultTypeAdapters.java:510)
          at com.google.gson.JsonSerializationVisitor.findAndInvokeCustomSerialize
  r(JsonSerializationVisitor.java:184)
          at com.google.gson.JsonSerializationVisitor.visitUsingCustomHandler(Json
  SerializationVisitor.java:160)
          at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:106)
          at com.google.gson.JsonSerializationContextDefault.serialize(JsonSeriali
  zationContextDefault.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 play.mvc.results.RenderJson.&lt;init&gt;(RenderJson.java:20)
          at play.mvc.Controller.renderJSON(Controller.java:325)
          at controllers.Application.getNews(Application.java:43)
          at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:540)
  
          at play.mvc.ActionInvoker.invoke(ActionInvoker.java:498)
          at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:474)
  
          at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:469)
  
          at play.mvc.ActionInvoker.invoke(ActionInvoker.java:157)
          ... 1 more
  Caused by: com.google.gson.CircularReferenceException: circular reference error
          at com.google.gson.JsonSerializationVisitor.start(JsonSerializationVisit
  or.java:56)
          at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:114)
          at com.google.gson.JsonSerializationContextDefault.serialize(JsonSeriali
  zationContextDefault.java:56)
          at com.google.gson.JsonSerializationContextDefault.serialize(JsonSeriali
  zationContextDefault.java:49)
          at com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter.serialize(D
  efaultTypeAdapters.java:528)
          at com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter.serialize(D
  efaultTypeAdapters.java:510)
          at com.google.gson.JsonSerializationVisitor.findAndInvokeCustomSerialize
  r(JsonSerializationVisitor.java:184)
          at com.google.gson.JsonSerializationVisitor.visitFieldUsingCustomHandler
  (JsonSerializationVisitor.java:203)
          ... 27 more
  </code></pre>