title: Spring 3 with ResponseBody ignoring @JsonTypeInfo
body: <p>I can't make spring return a serialization of my object with the additional property defining the class.</p>
  
  <p>My classes are:</p>
  
  <pre><code>@JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include= JsonTypeInfo.As.PROPERTY, property="ObjectType")
  @JsonSubTypes({
      @JsonSubTypes.Type(value=LiteStudy.class, name="LiteStudy")
  })
  public class Entity {
  ...
  }
  
  
  @JsonTypeName("LiteStudy")
  @JsonSubTypes({
          @JsonSubTypes.Type(value=Study.class, name="Study")
  })
  public class LiteStudy extends Entity {
  ...
  }
  
  
  @JsonTypeName("Study")
  public class Study extends LiteStudy{
  ...
  }
  </code></pre>
  
  <p>In my unit test, an Study instance is serialised properly, having the extra property for the class:</p>
  
  <pre><code>{"ObjectType":"Study",
  ...
  }
  </code></pre>
  
  <p>Using for this a simple:</p>
  
  <pre><code>ObjectMapper mapper = new ObjectMapper();
  mapper.readValue(studyJSON,study.getClass());
  </code></pre>
  
  <p>However, in my Spring Rest webservice module the study is serialized without the "ObjectType" property.</p>
  
  <p>The controller looks like this (simplified):</p>
  
  <pre><code>@ResponseBody
  public RestResponse&lt;Study&gt; getStudyById(@PathVariable("studyIdentifier")    String studyIdentifier) throws DAOException {
  
      return getStudyRestResponse(studyIdentifier);
  }
  </code></pre>
  
  <p>EDIT: Adding RestResponse (Simplified)</p>
  
  <pre><code>public class RestResponse&lt;Content&gt; {
  
  private Content content;
  private String message;
  private Exception err;
  
  public Content getContent() {
      return content;
  }
  
  public void setContent(Content content) {
      this.content = content;
  }
  
  public String getMessage() {
      return message;
  }
  
  public void setMessage(String message) {
      this.message = message;
  }
  
  public Exception getErr() {
      return err;
  }
  
  public void setErr(Exception err) {
      this.err = err;
  }
  </code></pre>
  
  <p>Any idea why spring seems to be ignoring the @JsonType annotations?</p>