title: Serializing responses in Jersey+Jackson
body: <p>I am trying to understand whether it is possible to serialize a java Map to a Json response from Jersey.</p>
  
  <p>Here is my service :</p>
  
  <pre><code>@Singleton
  @Path("/")
  public class ApiServiceResource {
      @Inject
      ISeedingUpdateService seedingUpdateService;
  
      @GET
      @Produces(MediaType.APPLICATION_JSON)
      @Path("/map")
      public List&lt;String&gt; getMap() {
          return newArrayList(seedingUpdateService.toString());
      }
      @GET
      @Produces(MediaType.APPLICATION_JSON)
      @Path("/pojo")
      public TemplateMessage getTemplateMessage(@PathParam("param") String param) {
          return new TemplateMessage(param, seedingUpdateService.toString());
      }
  
      @XmlRootElement
      public static class TemplateMessage {
          public Map&lt;String,String &gt; param;
          public TemplateMessage() {
          }
          public TemplateMessage(String param1, String param2) {
              this.param = newHashMap();
              this.param.put(param1,param2);
          }
      }
  }
  </code></pre>
  
  <p>The getMap method fails since it cannot serialize the Map --> </p>
  
  <pre><code>SEVERE: The registered message body writers compatible with the MIME media type are:
  application/json -&gt;
    com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$App
    com.sun.jersey.json.impl.provider.entity.JSONArrayProvider$App
    com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$App
    com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$App
    com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$App
  */* -&gt;
  </code></pre>
  
  <p>And the second method works just fine the POJO is serialized with the Map inside.</p>
  
  <p>Is there something that i am missing ?</p>
  
  <p>By the way the app is configured in Guice , so here is the guice configuration : </p>
  
  <pre><code>@Override
  protected void configureServlets() {
      bind(ApiServiceResource.class);
      /* bind jackson converters for JAXB/JSON serialization */
      bind(MessageBodyReader.class).to(JacksonJsonProvider.class);
      bind(MessageBodyWriter.class).to(JacksonJsonProvider.class);
      Map&lt;String,String&gt; parameters = newHashMap();
      parameters.put("com.sun.jersey.config.property.packages", "com.delver.update.api");
      serve("/rest/*").with(GuiceContainer.class, parameters);
  }
  </code></pre>