title: JSON to object issue with Jersey and Genson
body: <p>I'm running into the following problem when trying to execute a POST call using Jersey and Genson:</p>
  
  <p>....
  com.owlike.genson.JsonBindingException: No constructor has been found for type interface Animal
  ....</p>
  
  <p>I have the following setup:</p>
  
  <p>-> Animal.java</p>
  
  <pre><code>package com.test;
  
  import org.codehaus.jackson.annotate.JsonSubTypes;
  import org.codehaus.jackson.annotate.JsonTypeInfo;
  
  @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
  @JsonSubTypes( {@JsonSubTypes.Type(value = Dog.class, name = "dog") })
  public interface Animal
  {  }
  </code></pre>
  
  <p>-> Dog.java</p>
  
  <pre><code>package com.test;
  
  import org.codehaus.jackson.annotate.JsonTypeName;
  import org.codehaus.jackson.annotate.JsonProperty;
  
  @JsonTypeName("dog")
  public class Dog implements Animal
  {
     @JsonProperty
     public String name;
  
     public String getName() { return name; }
     public void setName(String n) { this.name = n; }
  }
  </code></pre>
  
  <p>-> Zoo.java </p>
  
  <pre><code>package com.test;
  
  import java.util.List;
  
  public class Zoo
  {
     private List&lt;Animal&gt; animals;
     public List&lt;Animal&gt; getAnimals()
     {
       return animals;
     }
  
     public void setAnimals(List&lt;Animal&gt; animals)
     {
      this.animals = animals;
      } 
   }
  </code></pre>
  
  <p>-> GensonCustomResolver.java</p>
  
  <pre><code>package com.test;
  import javax.ws.rs.next.ContextResolver;
  import javax.ws.rs.next.Provider;
  
  import com.owlike.genson.Genson;
  
  @Provider
  public class GensonCustomResolver implements ContextResolver&lt;Genson&gt;
  {
     private final Genson genson = new      Genson.Builder().useRuntimeType(true).useClassMetadata(true).create();
  
     @Override
     public Genson getContext(Class&lt;?&gt; arg0)
     {
       return genson;
     }
  }
  </code></pre>
  
  <p>-> JerseyService.java</p>
  
  <pre><code>package com.test;
  
  import javax.ws.rs.*;
  import org.codehaus.jackson.*;
  
  @Path("/exampleservice")
  public class JerseyService 
  {
  
  
     @POST
     @Path("somePath")
     @Consumer(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
     public Zoo createAnotherZoo(Zoo zoo) throws JsonParseException, JsonMappingException, Exception
     {
        Zoo newZoo = new Zoo();
        Collection&lt;Animal&gt; animals = zoo.getAnimals();
        List&lt;Animal&gt; newAnimals = new ArrayList&lt;Animal&gt;();
  
        for (Animal a : animals) {
            Dog dog_a = (Dog) a;
            Dog dog_b = new Dog();
            dog_b.setName(dog_a.getName() + "TEST");
            newAnimals.add(dog_b);
        }
        newZoo.add(newAnimals);
        return newZoo;
     }
  }
  </code></pre>
  
  <p>The input JSON looks like this:</p>
  
  <pre><code>{
     "animals" : [
       {
         "name": "Unno"
       }
      ]
  }
  </code></pre>
  
  <p>To summarize, I have a List and I'm trying to use one of the interface implementations when deserializing my objects.</p>
  
  <p>Thank you in advance.</p>
  
  <p>::::SOLUTION:::::</p>
  
  <p>In case anyone runs into this:</p>
  
  <p>I removed genson dependencies completely as suggested below. Only used jackson annotations and it seemed to work. Also I removed the @JsonProperty from the name attribute in the Dog.java.</p>
  
  <p>Thank you :) :)</p>