title: How to configure Jackson to deserialize named types with default typing?
body: <p>Consider the following example:</p>
  
  <pre><code>package com.example;
  
  import com.fasterxml.jackson.annotation.JsonTypeInfo;
  import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
  import com.fasterxml.jackson.annotation.JsonTypeName;
  import com.fasterxml.jackson.databind.ObjectMapper;
  import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping;
  
  public class JacksonDeserializationOfNamedTypes {
      public static void main(String[] args) throws Exception {
          ObjectMapper jackson = new ObjectMapper();
          jackson.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "@type");
  
          Balloon redBalloon = new Balloon("red");
  
          String json = jackson.writeValueAsString(redBalloon); //{"@type":"Balloon","color":"red"}
          //assume the JSON could be anything
          Object deserialized = jackson.readValue(json, Object.class);
  
          assert deserialized instanceof Balloon;
          assert redBalloon.equals(deserialized);
      }
  
      @JsonTypeName("Balloon")
      @JsonTypeInfo(use = Id.NAME)
      public static final class Balloon {
          private final String color;
  
          //for deserialization
          private Balloon() {
              this.color = null;
          }
  
          public Balloon(final String color) {
              this.color = color;
          }
  
          public String getColor() {
              return color;
          }
  
          @Override
          public boolean equals(final Object obj) {
              if (this == obj) return true;
              if (obj == null || getClass() != obj.getClass()) return false;
              final Balloon other = (Balloon) obj;
              return this.color.equals(other.color);
          }
  
          @Override
          public int hashCode() {
              int result = color.hashCode();
              result = 31 * result + color.hashCode();
              return result;
          }
  
          @Override
          public String toString() {
              return color + " balloon";
          }
      }
  }
  </code></pre>
  
  <p>The deserialization fails at runtime with the following exception:
  <code>Exception in thread "main" java.lang.IllegalArgumentException: Invalid type id 'Balloon' (for id type 'Id.class'): no such class found</code></p>
  
  <p>The produced JSON certainly has all the information Jackson needs to determine the type correctly, so how can I configure the ObjectMapper to properly map <code>"Balloon"</code> to <code>com.example.JacksonDeserializationOfNamedTypes$Balloon</code>?</p>