title: Deserializing abstract property from JSON request body, based on another property from that body
body: <p>How to properly deserialize an object from JSON (using Jackson) when it has an abstract property of which the conrete implementation depends on another property from that request body?</p>
  
  <p>This is probably best described on an example.</p>
  
  <p>Request body for my REST endpoint includes a property which is an abstract type with multiple concrete implementations which should be deserialized based on the <code>discriminator</code> property:</p>
  
  <pre><code>@Getter
  @Builder
  @AllArgsConstructor
  public class SomeRequestBody {
  
      @NotNull
      @NotBlank
      @NumberFormat
      private final String discriminator;
  
      @NotNull
      private final SomeAbstractClass someAbstractClass;
  
  }
  </code></pre>
  
  <p>Abstract class in question</p>
  
  <pre><code>@Getter
  @AllArgsConstructor
  public abstract class SomeAbstractClass{
  
      @NotNull
      @NotBlank
      protected final String commonProperty;
  
  }
  </code></pre>
  
  <p>Example implementation of the abstract class</p>
  
  <pre><code>@Getter
  public class ConcreteImplementationA extends SomeAbstractClass {
  
      @Builder
      @JsonCreator
      public ConcreteImplementationA(
          @NotNull @NotBlank @JsonProperty("commonProperty") String commonProperty,
          @NotNull @NotBlank @JsonProperty("specificProperty") Date specificProperty) {
              super(commonProperty);
              this.specificProperty = specificProperty;
      }
  
      @NotNull
      @NotBlank
      private final String specificProperty;
  
  }
  </code></pre>
  
  <p>What I tried...</p>
  
  <pre><code>@Getter
  @Builder
  @AllArgsConstructor
  public class SomeRequestBody {
  
      @NotNull
      @NotBlank
      @NumberFormat
      private final String discriminator;
  
      @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXTERNAL_PROPERTY, property = "discriminator")
      @JsonSubTypes({
          @JsonSubTypes.Type(value = ConcreteImplementationA.class, name = "1"),
          Other implementations...)
      })
      @NotNull
      private final SomeAbstractClass someAbstractClass;
  
  }
  </code></pre>
  
  <p>However, I'm getting the following exception:</p>
  
  <pre><code>"Type definition error: [simple type, class abc.SomeRequestBody]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `abc.SomeRequestBody`, problem: Internal error: no creator index for property 'someAbstractClass' (of type com.fasterxml.jackson.databind.deser.impl.FieldProperty)\n at [Source: (PushbackInputStream); line: 8, column: 1]"
  </code></pre>
  
  <p>What is the proper way to achieve what I need?</p>