title: Jersey test keeps failing with MessageBodyReader not found when reading entity?
body: <p>I have a REST api that returns an object in json format, with <code>Content-Type</code> of <code>application/json</code>, pretty standard.</p>
  
  <p>I'm creating a basic TestNg Jersey test using Jersey's test framework, and want to run a simple test against an external container deployed independently in Tomcat.</p>
  
  <p>The setup seems OK for tests that don't need to read the entity of a response, but those that do fail with:</p>
  
  <pre><code>org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyReader not found for media type=application/json, type=class com.test.Status, genericType=class com.specktro.orchid.rest.api.Status.
      at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:225)
      at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:149)
      at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1124)
      at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:851)
      at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:783)
      at org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:326)
      at org.glassfish.jersey.client.InboundJaxrsResponse$1.call(InboundJaxrsResponse.java:111)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
      at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:399)
      at org.glassfish.jersey.client.InboundJaxrsResponse.readEntity(InboundJaxrsResponse.java:108)
      at com.specktro.orchid.rest.api.tests.CoreTest.test(CoreTest.java:81)
      at com.specktro.orchid.rest.api.tests.CoreTest.second(CoreTest.java:46)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
      at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
      at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
      at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
      at org.testng.TestRunner.privateRun(TestRunner.java:767)
      at org.testng.TestRunner.run(TestRunner.java:617)
      at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
      at org.testng.SuiteRunner.access$000(SuiteRunner.java:37)
      at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:368)
      at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
      at java.util.concurrent.FutureTask.run(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>I'm configuring the test like so:</p>
  
  <pre><code>public class CoreTest extends ContainerPerClassTest {
  
      @Override
      public TestContainerFactory getTestContainerFactory() {
          return new ExternalTestContainerFactory();
      }
  
      @Override
      protected Application configure() {
          return new ResourceConfig();
      }
  
      @Test
      private void test() {
          final Response response = target("/status").request()
                  .accept(MediaType.APPLICATION_JSON).get();
  
          Assert.assertEquals(response.getStatus(), 200);
  
          // FAILS HERE
          Status status = response.readEntity(Status.class);
      }
  
      ...
  
  }
  </code></pre>
  
  <p>At the indicated line it fails with <code>response.readEntity(Status.class);</code>.</p>
  
  <p>This is a Maven project, and these are the relevant dependencies:</p>
  
  <pre><code>  &lt;dependencies&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
        &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
        &lt;version&gt;2.4.1.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.fasterxml.jackson.jaxrs&lt;/groupId&gt;
        &lt;artifactId&gt;jackson-jaxrs-json-provider&lt;/artifactId&gt;
        &lt;version&gt;2.4.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
        &lt;artifactId&gt;jersey-container-servlet&lt;/artifactId&gt;
        &lt;version&gt;2.9.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
        &lt;version&gt;2.9.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-common&lt;/artifactId&gt;
        &lt;version&gt;2.9.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.test-framework&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-test-framework-core&lt;/artifactId&gt;
          &lt;version&gt;2.10.1&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.test-framework.providers&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-test-framework-provider-bundle&lt;/artifactId&gt;
          &lt;version&gt;2.10.1&lt;/version&gt;
          &lt;type&gt;pom&lt;/type&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt; 
          &lt;groupId&gt;org.testng&lt;/groupId&gt;
          &lt;artifactId&gt;testng&lt;/artifactId&gt;
          &lt;version&gt;6.8.8&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
    &lt;/dependencies&gt;
  </code></pre>
  
  <p>The <code>com.test.Status</code> class I'm trying to read has an empty constructor as required by JAX-RS.</p>
  
  <p>Anyone knows why the test would fail like this? As you can see I'm using Jersey 2.x.</p>
  
  <p>Any help is greatly appreciated!</p>
  
  <p>Thanks!</p>