title: Jackson annotations not used with Spring boot
body: <p>I am using Spring boot 1.0.1.RELEASE and am trying to get it to pick up some Jackson annotations. More specifically, I am trying to use <code>@JsonManagedReference</code> and <code>@JsonBackReference</code> annotations. Any idea why this might get ignored? I also tried <code>@JsonIgnore</code> but that also did not seem to get picked up.</p>
  
  <p>I already tried the 2 things mentioned <a href="https://stackoverflow.com/questions/16881382/jsonignore-and-jsonbackreference-are-being-ignored">in this SO question</a> (Moving the Jackson annotionations to be first and using a <code>List</code> instead of a <code>Set</code>). I also looked at <a href="http://forum.spring.io/forum/jpa-orm/747479-jsonmanagedreference-doesn-t-seem-to-do-anything" rel="nofollow noreferrer">this question on the Spring forums</a>, but that does not help me either.</p>
  
  <p>UPDATE:</p>
  
  <p>This is my <code>ComponentType</code> class:</p>
  
  <pre><code>@Entity
  public class ComponentType
  {
  // ------------------------------ FIELDS ------------------------------
  
      @Id
      @GeneratedValue()
      private long m_id;
  
      private String m_name;
  
      @JsonManagedReference
      @OneToMany(cascade = CascadeType.ALL)
      @JoinColumn(name = "parent_id")
      private List&lt;ComponentSubtype&gt; m_subtypes;
  
  // --------------------------- CONSTRUCTORS ---------------------------
  
      public ComponentType()
      {
      }
  
      public ComponentType( String name, Iterable&lt;ComponentSubtype&gt; subtypes )
      {
          m_name = name;
          m_subtypes = Lists.newArrayList(subtypes);
      }
  
      // -------------------------- PUBLIC METHODS --------------------------
  
      public long getId()
      {
          return m_id;
      }
  
      public void setId( long id )
      {
          m_id = id;
      }
  
      public String getName()
      {
          return m_name;
      }
  
      public void setName( String name )
      {
          m_name = name;
      }
  
      public List&lt;ComponentSubtype&gt; getSubtypes()
      {
          return m_subtypes;
      }
  
      public void setSubtypes( List&lt;ComponentSubtype&gt; subtypes )
      {
          m_subtypes = subtypes;
      }
  
      public ComponentSubtype getSubtype( final long subtypeId )
      {
          return Iterables.find( getSubtypes(), new Predicate&lt;ComponentSubtype&gt;()
          {
              @Override
              public boolean apply( ComponentSubtype input )
              {
                  return input.getId() == subtypeId;
              }
          } );
      }
  </code></pre>
  
  <p>And this is <code>ComponentSubtype</code>:</p>
  
  <pre><code>@Entity
  public class ComponentSubtype
  {
      @Id
      @GeneratedValue()
      private long m_id;
  
      private String m_name;
  
      @JsonBackReference
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "parent_id",insertable=false,updatable=false)
      private ComponentType m_componentType;
  
      public ComponentSubtype()
      {
      }
  
      public ComponentSubtype( String name )
      {
          m_name = name;
      }
  
      public long getId()
      {
          return m_id;
      }
  
      public void setId( long id )
      {
          m_id = id;
      }
  
      public String getName()
      {
          return m_name;
      }
  
      public void setName( String name )
      {
          m_name = name;
      }
  
      public ComponentType getComponentType()
      {
          return m_componentType;
      }
  
      public void setComponentType( ComponentType componentType )
      {
          m_componentType = componentType;
      }
  }
  </code></pre>
  
  <p>The controller:</p>
  
  <pre><code>@RestController
  @RequestMapping("/api/components")
  public class ComponentTypeController
  {
      @Autowired
      private ComponentTypeRepository m_repository;
  
      @RequestMapping("/list")
      public Iterable&lt;ComponentType&gt; listComponents()
      {
          return m_repository.findAll();
      }
  }
  </code></pre>
  
  <p>And the repository:</p>
  
  <pre><code>public interface ComponentTypeRepository extends CrudRepository&lt;ComponentType, Long&gt;
  {
  }
  </code></pre>
  
  <p>In my main I create some entities for testing:</p>
  
  <pre><code>    ConfigurableApplicationContext context = SpringApplication.run( Main.class, args );
  ComponentTypeRepository componentTypeRepository = context.getBean( ComponentTypeRepository.class );
  componentTypeRepository.save( new ComponentType( "Component A", Sets.newHashSet( new ComponentSubtype( "Sub A - 1" ), new ComponentSubtype( "Sub A - 2" ) ) ) );
  componentTypeRepository.save( new ComponentType( "Component B", Sets.newHashSet( new ComponentSubtype( "Sub B - 1" ), new ComponentSubtype( "Sub B - 2" ) ) ) );
  componentTypeRepository.save( new ComponentType( "Component C", Sets.newHashSet( new ComponentSubtype( "Sub C - 1" ), new ComponentSubtype( "Sub C - 2" ) ) ) );
  componentTypeRepository.save( new ComponentType( "Component D", Sets.newHashSet( new ComponentSubtype( "Sub D - 1" ),
                                                                                   new ComponentSubtype( "Sub D - 2" ),
                                                                                   new ComponentSubtype( "Sub D - 3" )
  ) ) );
  </code></pre>
  
  <p>If I point my browser to <code>http://localhost:8080/api/components/list</code>, then I get a stackoverflow exception.</p>
  
  <p>This is part of the stacktrace I get:</p>
  
  <pre><code>java.lang.StackOverflowError: null
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
      at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
      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.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)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:117)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23)
      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)
      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)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:117)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23)
      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)
      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)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:117)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23)
      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)
      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)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:117)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23)
      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)
      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)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:117)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23)
      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)
      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)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:117)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23)
      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)
      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)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:117)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23)
      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)
      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)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:117)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23)
      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)
      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)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:117)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23)
      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)
      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)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:117)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23)
      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)
      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)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:117)
      at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23)
  </code></pre>
  
  <p>EXAMPLE PROJECT that demonstrates the problem:</p>
  
  <p>Download from <a href="https://dl.dropboxusercontent.com/u/6373261/jackson-problem.zip" rel="nofollow noreferrer">https://dl.dropboxusercontent.com/u/6373261/jackson-problem.zip</a></p>