title: Json (fasterxml) stackoverflow exception
body: <p>When trying to serialize a Category I get a stackoverflow.</p>
  
  <p><strong>Exception</strong></p>
  
  <blockquote>
    <p>Warning:   StandardWrapperValve[dispatcher]: Servlet.service() for
    servlet dispatcher threw exception java.lang.StackOverflowError   at
    java.lang.ClassLoader.defineClass1(Native Method)     at
    java.lang.ClassLoader.defineClass(ClassLoader.java:760)   at
    org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.findClass(BundleWiringImpl.java:2279)
      at
    org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1501)
      at
    org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
      at
    org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)    at
    com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:660)
      at
    com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:152)
      at
    com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:100)
      at
    com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:21)
      at
    com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.java:183)
      at
    com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:541)
      at
    com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:644)
      at
    com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:152)</p>
  </blockquote>
  
  <p><strong>Category.java</strong></p>
  
  <pre><code>@Entity
  public class Category implements DataObject, Serializable {
  
      @Id
      @GeneratedValue 
      private Long id;
      private String title;
      private String description;
  
      @ManyToOne @JsonIgnore 
      private Category parent;
  
  
  @Override
  public long getId() {
      return id;
  }
  
  @Override
  public void setId(long id) {
      this.id = id;
  }
  
  public String getTitle() {
      return title;
  }
  
  public void setTitle(String title) {
      this.title = title;
  }
  public String getDescription() {
      return description;
  }
  
  public void setDescription(String description) {
      this.description = description;
  }
  
  public Category getParent() {
     return null;//return parent;
  }
  
  public void setParent(Category parent) {
     // this.parent = parent;
  }
  
  public boolean isMainCategory()
  {
     return true;// return this.parent == null;
  }
  
  /**
   * Returns the chain of parent categories with the main category on index 0
   * @return Chain of categories 
   */
  public List&lt;Category&gt; getParentChain()
  {
  
     List&lt;Category&gt; cats = new ArrayList&lt;&gt;();
      Category current = this;
      while(!current.isMainCategory())
      {
          cats.add(current);
          current = current.getParent();
      }
      cats.add(current);
      Collections.reverse(cats);
      return cats;
  }
  
  @Override
  public String toString()
  {
      return this.title;
  }
  
  @Override
  public boolean equals(Object o)
  {
      if(!(o instanceof Category))return false;
      Category c = (Category)o;
  
      return c.title.equals(this.title);
  }
  
  @Override
  public int hashCode()
  {
      return super.hashCode();
  } 
  }
  </code></pre>
  
  <p><strong>Rest Controller function</strong></p>
  
  <pre><code>@RequestMapping(value="/{id}", method=RequestMethod.GET)
  public ResponseEntity&lt;Category&gt; get(@PathVariable("id") long categoryId)
  {
      Category c  =  service.getCategoryRepository().ReadValue(categoryId);
      if(c == null)
          return new ResponseEntity&lt;&gt;(HttpStatus.NOT_FOUND);
      return new ResponseEntity&lt;&gt;(c,HttpStatus.OK);
  }
  </code></pre>
  
  <p><strong>Note</strong></p>
  
  <p>Even when I replace <code>return new ResponseEntity&lt;&gt;(c,HttpStatus.OK);</code> with <code>return new ResponseEntity&lt;&gt;(new Category(),HttpStatus.OK);</code> I will get a stackoverflow whilist none of the fields contain a value.</p>
  
  <p>It works fine with my other classes it's only this class that causes a stackoverflow.</p>