title: How do I get a reference to the Jackson Object Mapper in a jersey2 / hk2 application
body: <p>I have a jersey2 application configured for JSON support via Jackson, adding</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
      &lt;artifactId&gt;jersey-media-json-jackson&lt;/artifactId&gt;
      &lt;version&gt;${jersey.version}&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>in the POM file and </p>
  
  <pre><code>public MyApplication() {
      ...
      register(JacksonFeature.class)
      ...
  }
  </code></pre>
  
  <p>in my application. Everything works, my resources get deserialized POJOs as arguments</p>
  
  <pre><code>@POST @Consumes(MediaType.APPLICATION_JSON)
  public void blah(MyPojo p) {
      ...
  }
  </code></pre>
  
  <p>Now one of thoese resources needs a reference to Jackson's <code>ObjectMapper</code> to do some deserialization on its own. I've tried doing something like</p>
  
  <pre><code>@Inject
  public MyResource(@Context ObjectMapper mapper) {
      ...
  }
  </code></pre>
  
  <p>or </p>
  
  <pre><code>@GET
  public String foo(@Context ObjectMapper mapper) {
      ...
  }
  </code></pre>
  
  <p>but in both cases the reference to <code>mapper</code> is null. How can I inject a reference to the <code>ObjectMapper</code> in my resources?</p>