title: jackson throw JsonMappingException can not construct instance of
body: <p>//interface</p>
  
  <pre><code>public interface NotificationPayload {
  }
  </code></pre>
  
  <p>//Classes implement interface</p>
  
  <pre><code>public ClassA implements NotificationPayload {...}
  public ClassB implements NotificationPayload {...}
  ...
  public ClassX implements NotificationPayload {...}
  </code></pre>
  
  <p>//Message to send</p>
  
  <pre><code>public class Notification&lt;T extends NotificationPayload&gt; {
      private T data; //T may be ClassA/ClassB/ClassC.../ClassX
      ...
  }
  </code></pre>
  
  <p>When I receive a message as a json, I want to convert it to Notification again by using ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)</p>
  
  <p>json example:</p>
  
  <pre><code>{
      "type":"ClassA",
      "userId":10087
  }
  </code></pre>
  
  <p>I convert it:</p>
  
  <pre><code>Notification notif = objectMapper.readValue(json, Notification.class);
  </code></pre>
  
  <p>it throw exception:</p>
  
  <pre><code>java.lang.IllegalArgumentException: Can not construct instance of 
  com.common.kafka.notification.NotificationPayload: abstract types
  either need to be mapped to concrete types, have custom deserializer, or
  contain additional type information
  at [Source: N/A; line: -1, column: -1] (through reference chain:
  com.common.kafka.notification.Notification["data"])
  </code></pre>
  
  <p>I had read from this question: <a href="https://stackoverflow.com/questions/12750681/cannot-construct-instance-of-jackson#">Cannot construct instance of - Jackson</a> but seem like It cannot help because I have too many Class implement from interface, not only once.</p>