title: Jackson: "Conflicting setter definitions for property" in JUnit Tests
body: <p>I have an application that queries EC2 <code>Instance</code> data using Amazon's AWS SDK for Java.  The Instance is serialized to a JSON String using the <code>Jackson</code> wrapper class included in the AWS SDK.  Later, I'm able to use the <code>Jackson.fromJsonString(String, Class)</code> method to deserialize the JSON String back into an EC2 <code>Instance</code> object.</p>
  
  <p>This all works great in my application code.  However, it fails every single time when run from a JUnit test within Eclipse.  I'm using the exact same data, and the exact same deserialization code.  When I run it from a JUnit test, though, I get the following Exception:</p>
  
  <pre><code>com.amazonaws.SdkClientException: Unable to parse Json String.
      at com.amazonaws.util.json.Jackson.fromJsonString(Jackson.java:66)
      at com.myapp.filters.test.AbstractResourceFilterCriteriaTest.testMeetsCriteria_Fail(AbstractResourceFilterCriteriaTest.java:166)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
  Caused by: com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "instanceType": com.amazonaws.services.ec2.model.Instance#setInstanceType(1 params) vs com.amazonaws.services.ec2.model.Instance#setInstanceType(1 params)
      at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:269)
      at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
      at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
      at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:461)
      at com.fasterxml.jackson.databind.ObjectMapper._findRootDeserializer(ObjectMapper.java:3838)
      at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3732)
      at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2726)
      at com.amazonaws.util.json.Jackson.fromJsonString(Jackson.java:64)
      ... 26 more
  Caused by: java.lang.IllegalArgumentException: Conflicting setter definitions for property "instanceType": com.amazonaws.services.ec2.model.Instance#setInstanceType(1 params) vs com.amazonaws.services.ec2.model.Instance#setInstanceType(1 params)
      at com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder.getSetter(POJOPropertyBuilder.java:300)
      at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.filterBeanProps(BeanDeserializerFactory.java:619)
      at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.addBeanProps(BeanDeserializerFactory.java:515)
      at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:256)
      at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:169)
      at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:403)
      at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:352)
      at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:264)
      ... 33 more
  </code></pre>
  
  <p>Any idea what on earth could be going wrong here?  Why is it that it works just fine in the main application code, but fails when run as a JUnit test?  Since I don't own the <code>Instance</code> object (it's part of Amazon's SDK) I can't modify any Jackson annotations.  Any idea how I can get around this for my unit tests?</p>