title: Jackson deserialize Scala Future
body: <p>I'm trying to figure how to explain Jersey and Jackson how to deserialize a Future that I pass as byte[].</p>
  
  <p>I create my own ContextResolver</p>
  
  <pre><code>public class ObjectMapperContextResolver implements ContextResolver&lt;ObjectMapper&gt; {
  
      private static ObjectMapper mapper = null;
  
      public ObjectMapperContextResolver() {
          mapper = ObjectMapperFactory.getObjectMapper();     
      }
  
      @Override
      public ObjectMapper getContext(Class&lt;?&gt; type) {
          return mapper;
      }
  
  }
  </code></pre>
  
  <p>And the implementation of the ObjectMapper</p>
  
  <pre><code>public static ObjectMapper getObjectMapper() {
          ObjectMapper defaultObjectMapper = new ObjectMapper();
          SimpleModule futureModule = new SimpleModule("FutureModule");
          futureModule.&lt;Future&gt;addDeserializer(Future.class, new FutureDeserializer&lt;String&gt;());
          defaultObjectMapper.registerModule(futureModule);
          return defaultObjectMapper;
  }
  </code></pre>
  
  <p>And then finally in the implementation of my FutureDeserializer</p>
  
  <pre><code>public class FutureDeserializer&lt;T&gt; extends StdDeserializer&lt;Future&lt;T&gt;&gt;{
  
      public FutureDeserializer() {
          super(Future.class);
      }
  
      @Override
      public Future&lt;T&gt; deserialize(JsonParser jp, DeserializationContext ctxt)
              throws IOException {
          ObjectMapper mapper=(ObjectMapper)jp.getCodec();
          //TODO: Breakpoint never stop here
          return null;
      }
  }
  </code></pre>
  
  <p>Then I register in my <code>ResourceConfig</code> before start the <code>JerseyTest</code></p>
  
  <pre><code>ResourceConfig rc = new ResourceConfig();
          rc.register(SpringLifecycleListener.class);
          rc.register(RequestContextFilter.class);
          rc.register(new JacksonFeature());
          rc.register(new ObjectMapperContextResolver());
  </code></pre>
  
  <p>But when I run the test the ObjectMapperContextResolver is invoked and the mapper returned to Jersey, but he never use the FutureDeserializer.</p>
  
  <p>Any idea what I´m doing wrong?</p>