title: Jersey doesn't work with given provider
body: <p>I am working with Jersey and try to use the Gson provider instead of Jackson. I used the Blogpost by <a href="http://eclipsesource.com/blogs/2012/11/02/integrating-gson-into-a-jax-rs-based-application/" rel="nofollow">Moritz Post</a>.</p>
  
  <p>The REST service I defined:
  @Path("user")</p>
  
  <pre><code>public class UserResource extends AbstractResource {
      @POST
      @Path("auth")
      @Consumes(MediaType.APPLICATION_JSON)
      public String postAuth(Login obj) {
          // Session session = HibernateHelper.getSessionFactory().openSession();
          //Login obj = new Gson().fromJson(json, Login.class);
          return "Response: " + obj;
      }
  }
  </code></pre>
  
  <p>It returns: Response: null null</p>
  
  <p>When I use the Gson-provider explicitly:</p>
  
  <pre><code>@Path("user")
  public class UserResource extends AbstractResource {
  
      @POST
      @Path("auth")
      @Consumes(MediaType.APPLICATION_JSON)
      public String postAuth(String json) {
          Login obj = new Gson().fromJson(json, Login.class);
          return "Response: " + obj;
      }
  }
  </code></pre>
  
  <p>It returns: Response: Username Password</p>
  
  <p>I explicitly registered the Provider at Grizzly:</p>
  
  <pre><code>rc.register(GsonProvider.class);
  </code></pre>
  
  <p>The following code for the provider:</p>
  
  <pre><code>import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.OutputStream;
  import java.io.OutputStreamWriter;
  import java.io.UnsupportedEncodingException;
  import java.lang.annotation.Annotation;
  import java.lang.reflect.Type;
  
  import javax.ws.rs.Consumes;
  import javax.ws.rs.Produces;
  import javax.ws.rs.WebApplicationException;
  import javax.ws.rs.core.MediaType;
  import javax.ws.rs.core.MultivaluedMap;
  import javax.ws.rs.ext.MessageBodyReader;
  import javax.ws.rs.ext.MessageBodyWriter;
  import javax.ws.rs.ext.Provider;
  
  import com.google.gson.Gson;
  import com.google.gson.GsonBuilder;
  
  @Provider
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  public final class GsonProvider implements MessageBodyWriter&lt;Object&gt;,
          MessageBodyReader&lt;Object&gt; {
  
      private static final String UTF_8 = "UTF-8";
  
      private Gson gson;
  
      private Gson getGson() {
          System.out.println("ja");
  
          if (gson == null) {
              final GsonBuilder gsonBuilder = new GsonBuilder();
              gson = gsonBuilder.create();
          }
          return gson;
      }
  
      @Override
      public boolean isReadable(Class&lt;?&gt; type, Type genericType,
              java.lang.annotation.Annotation[] annotations, MediaType mediaType) {
          return true;
      }
  
      @Override
      public Object readFrom(Class&lt;Object&gt; type, Type genericType,
              Annotation[] annotations, MediaType mediaType,
              MultivaluedMap&lt;String, String&gt; httpHeaders, InputStream entityStream)
              throws IOException {
          InputStreamReader streamReader = new InputStreamReader(entityStream,
                  UTF_8);
          try {
              Type jsonType;
              if (type.equals(genericType)) {
                  jsonType = type;
              } else {
                  jsonType = genericType;
              }
              return getGson().fromJson(streamReader, jsonType);
          } finally {
              streamReader.close();
          }
      }
  
      @Override
      public boolean isWriteable(Class&lt;?&gt; type, Type genericType,
              Annotation[] annotations, MediaType mediaType) {
          return true;
      }
  
      @Override
      public long getSize(Object object, Class&lt;?&gt; type, Type genericType,
              Annotation[] annotations, MediaType mediaType) {
          return -1;
      }
  
      @Override
      public void writeTo(Object object, Class&lt;?&gt; type, Type genericType,
              Annotation[] annotations, MediaType mediaType,
              MultivaluedMap&lt;String, Object&gt; httpHeaders,
              OutputStream entityStream) throws IOException,
              WebApplicationException {
          OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8);
          try {
              Type jsonType;
              if (type.equals(genericType)) {
                  jsonType = type;
              } else {
                  jsonType = genericType;
              }
              getGson().toJson(object, jsonType, writer);
          } finally {
              writer.close();
          }
      }
  }
  </code></pre>