title: Jetty + Jersey + Jackson, different behavior in Eclipse (Success) vs command line (Error Unsupported Media Type)!
body: <p>I'm getting crazy trying to run Jetty Jersey and Jackson outside Eclipse.</p>
  
  <p>I have a main class:</p>
  
  <pre><code>public class Main {
  
      public static void main(String[] args) throws Exception {
  
          ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
          context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*").setInitParameter(
              "jersey.config.server.provider.classnames", CanaryEndpoint.class.getCanonicalName());
  
          Server jettyServer = new org.eclipse.jetty.server.Server(8089);
          jettyServer.setHandler(context);
          jettyServer.start();
          jettyServer.join();
      }
  }
  </code></pre>
  
  <p>An endpoint class: </p>
  
  <pre><code>@Path("/endpoint")
  public class CanaryEndpoint {
  
      @POST
      @Path("/test")
      @Consumes(MediaType.APPLICATION_JSON)
      @Produces(MediaType.APPLICATION_JSON)
      public String canaryTest(ValueWrapper param) {
          System.out.println("Deserialized Property: " + param.isFlag());
          return "{OK}";
      }
  }
  </code></pre>
  
  <p>and an Entity (to unserialize) class:</p>
  
  <pre><code>@XmlRootElement
  @XmlAccessorType(XmlAccessType.NONE)
  public class ValueWrapper {
      @XmlElement
      public boolean flag;
  
      public ValueWrapper() {}
      public boolean isFlag()           { return flag; }
      public void setFlag(boolean flag) { this.flag = flag;}
  }
  </code></pre>
  
  <p>Now it comes the funny part.
  I use Postman to test the JSON consuming by sending a POST petition to 8089 port and a raw JSON value of <code>{"flag" : "true"}</code> with both Content-type and Accept adequately set.</p>
  
  <p>When I play Main class through eclipse server answers correctly, but when I do it in the CLI (mvn clean package + java -cpJar main_class), server answers <strong>Error 415: Unsuported Media Type</strong></p>
  
  <p>My simple pom.xml:</p>
  
  <pre><code>&lt;jersey.version&gt;2.14&lt;/jersey.version&gt;
  &lt;jetty-version&gt;9.2.6.v20141205&lt;/jetty-version&gt;
  (...)
  &lt;artifactId&gt;jetty-server&lt;/artifactId&gt;
  &lt;artifactId&gt;jetty-servlet&lt;/artifactId&gt;
  &lt;artifactId&gt;jersey-container-servlet-core&lt;/artifactId&gt;
  &lt;artifactId&gt;jersey-json&lt;/artifactId&gt;
  &lt;artifactId&gt;jersey-media-json-jackson&lt;/artifactId&gt;
  </code></pre>
  
  <p>Any suggestion regarding what is happening?</p>
  
  <p><strong>EDIT: 
  I narrowed a bit the problem. Seems like com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider is not registering when the app is executed from the console</strong>. How can I manually register it?</p>