title: I have an overloaded setter on an object, how can I tell Jackson to ignore one of them?
body: <p>I'm using Jersey 1.17 with <code>com.sun.jersey.api.json.POJOMappingFeature</code> set to true and I'm POSTing an object that looks like this:</p>
  
  <pre><code>import com.fasterxml.jackson.annotation.JsonIgnore;
  
  import javax.xml.bind.annotation.XmlRootElement;
  import javax.xml.bind.annotation.XmlTransient;
  
  @XmlRootElement
  public class ByteArrayWithOverloadedSetterObject {
  
      private byte[] data;
  
      public void setData(byte[] data) {
          this.data = data;
      }
  
      @XmlTransient
      @JsonIgnore
      public void setData(String data) {
          this.data = data.getBytes();
      }
  
      public byte[] getData() {
          return data;
      }
  }
  </code></pre>
  
  <p>My Resource has this method:</p>
  
  <pre><code>@POST
  @Path("postByteArrayWithOverloadedSetterObject")
  public byte[] sendByteArrayWithOverloadedSetterObject(ByteArrayWithOverloadedSetterObject byteArrayWithOverloadedSetterObject) {
      if (byteArrayWithOverloadedSetterObject.getData() == null) {
          log.warn("data was null!");
      }
      return byteArrayWithOverloadedSetterObject.getData();
  }
  </code></pre>
  
  <p>And my client side unit tests are written like this:</p>
  
  <pre><code>@Test
  public void whenSendingStringDataThenGetDataBack() {
      ByteArrayWithOverloadedSetterObject byteArrayWithOverloadedSetterObject = new ByteArrayWithOverloadedSetterObject();
      byteArrayWithOverloadedSetterObject.setData("foobar");
      byte[] data = new AuthClient().postJaxbToUrl(RestApiUriBuilder.TEST_REST_PATH + "/postByteArrayWithOverloadedSetterObject", byteArrayWithOverloadedSetterObject, byte[].class);
      assertNotNull(data);
  }
  
  @Test
  public void whenSendingByteDataThenGetDataBack() {
      ByteArrayWithOverloadedSetterObject byteArrayWithOverloadedSetterObject = new ByteArrayWithOverloadedSetterObject();
      byteArrayWithOverloadedSetterObject.setData(new byte[]{0, 1, 1, 0});
      byte[] data = new AuthClient().postJaxbToUrl(RestApiUriBuilder.TEST_REST_PATH + "/postByteArrayWithOverloadedSetterObject", byteArrayWithOverloadedSetterObject, byte[].class);
      assertNotNull(data);
  }
  </code></pre>
  
  <p>Both of these tests are failing with a message that says "postByteArrayWithOverloadedSetterObject returned a response status of 204 No Content" and the server is logging "data was null!" for each.  Why isn't the byte array data being serialized over the wire?  I'm sending this as JSON.  </p>
  
  <p>If I comment out the <code>@XmlTransient</code>/<code>@JsonIgnore</code> annotations, I get this error: "java.lang.RuntimeException: Conflicting setter definitions for property "data"".</p>
  
  <p>In my real situation, I can't easily modify the API of <code>ByteArrayWithOverloadedSetterObject</code>.  But since this is just a test, I can see that things work correctly if I rename the second setter and the object becomes this:</p>
  
  <pre><code>import com.fasterxml.jackson.annotation.JsonIgnore;
  
  import javax.xml.bind.annotation.XmlRootElement;
  import javax.xml.bind.annotation.XmlTransient;
  
  @XmlRootElement
  public class ByteArrayWithOverloadedSetterObject {
  
      private byte[] data;
  
      public void setData(byte[] data) {
          this.data = data;
      }
  
      @XmlTransient
      @JsonIgnore
      public void setData2(String data) {  //RENAME HERE.  Now tests pass.
          this.data = data.getBytes();
      }
  
      public byte[] getData() {
          return data;
      }
  }
  </code></pre>
  
  <p>Since I can't change the API of <code>ByteArrayWithOverloadedSetterObject</code>, is there any other work around to this?  </p>