title: Jackson JSON deserialization with multiple parameters constructor
body: <p>I've been using FasterXML/Jackson-Databind in my project for a while now, and all was working great, until I've discovered this <a href="https://manosnikolaidis.wordpress.com/" rel="noreferrer">post</a> and started to use this approach to desserialize objects without the @JsonProperty annotations.</p>
  
  <p>The problem is that when I have a constructor which take multiple parameters and decorate this constructor with the @JsonCreator annotation Jackson throw the following error: </p>
  
  <pre><code>Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: 
  Argument #0 of constructor [constructor for com.eliti.model.Cruiser, annotations: {interface com.fasterxml.jackson.annotation.JsonCreator=@com.fasterxml.jackson.annotation.JsonCreator(mode=DEFAULT)}] has no property name annotation; must have name when multiple-parameter constructor annotated as Creator
   at [Source: {
    "class" : "com.eliti.model.Cruiser",
    "inventor" : "afoaisf",
    "type" : "MeansTransport",
    "capacity" : 123,
    "maxSpeed" : 100
  }; line: 1, column: 1]
  </code></pre>
  
  <p>I've created a <a href="https://github.com/pedro-stanaka/test-error-jackson" rel="noreferrer">little project</a> to illustrate the problem, the class I'm trying to desserialize is this one:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class Cruise extends WaterVehicle {
  
   private Integer maxSpeed;
  
    @JsonCreator
    public Cruise(String name, Integer maxSpeed) {
      super(name);
      System.out.println("Cruise.Cruise");
      this.maxSpeed = maxSpeed;
    }
  
    public Integer getMaxSpeed() {
      return maxSpeed;
    }
  
    public void setMaxSpeed(Integer maxSpeed) {
      this.maxSpeed = maxSpeed;
    }
  
  }
  </code></pre>
  
  <p>And the code to desserialize is like this: </p>
  
  <pre><code>public class Test {
    public static void main(String[] args) throws IOException {
      Cruise cruise = new Cruise("asd", 100);
      cruise.setMaxSpeed(100);
      cruise.setCapacity(123);
      cruise.setInventor("afoaisf");
  
      ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
      mapper.registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES));
  
      String cruiseJson = mapper.writeValueAsString(cruise);
  
      System.out.println(cruiseJson);
  
      System.out.println(mapper.readValue(cruiseJson, Cruise.class));
  
  }
  </code></pre>
  
  <p>I already tried to remove the @JsonCreator, but if I do so, the throws the following exception:</p>
  
  <pre><code>Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.eliti.model.Cruise: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?)
   at [Source: {
    "class" : "com.eliti.model.Cruise",
    "inventor" : "afoaisf",
    "type" : "MeansTransport",
    "capacity" : 123,
    "maxSpeed" : 100
  }; line: 3, column: 3]
  </code></pre>
  
  <p>I have tried to issue a "mvn clean install", but the problem persists.</p>
  
  <p>Just to include some extra information, I've researched thoroughly about this problem (GitHub issues, Blog posts, StackOverflow Q&amp;A). Here are some debbuging/investigation that I have been doing on my end:</p>
  
  <h3>Investigation 1</h3>
  
  <p><strong>javap -v</strong>  on the generated bytecode give me this:</p>
  
  <pre><code> MethodParameters:
        Name                           Flags
        name
        maxSpeed
  </code></pre>
  
  <p>When talking about the constructor, so I guess that the <strong>-parameters</strong> flag is really being set for javac compiler.</p>
  
  <h3>Investigation 2</h3>
  
  <p>If I create a constructor with a single parameter the object gets initialized, but I want/need to use the multiple parameter constructor.</p>
  
  <h3>Investigation 3</h3>
  
  <p>If I use the annotation @JsonProperty on each field it works as well, but for my original project it is too much overhead since I have a lot of fields in the constructor (and also it gets very hard to refactor code with annotations).</p>
  
  <p>The question that remain is:
  <strong>How can I make Jackson work with multiple parameter constructor without annotations?</strong></p>