title: NullPointerException is thrown when ApacheHttpClientHandler is used with Jersey1.18 for POST request
body: <p>We are consuming REST API using Jersey 1.18. We want to use Jakarta Commons HttpClient 3.1 as a backend while consuming the REST API. Therefore, we are using ApacheHttpClientHandler to get an object of Jersey Client from HttpClient. 
  It works fine for the GET request. However, when we make a call to a POST request, we get NullPointer Exception. Following is the extract from code with error message:</p>
  
  <p>/*Code for POST call which using ApacheHttpClientHandler the throws NPE */</p>
  
  <pre><code>import com.sun.jersey.api.client.Client;
  import com.sun.jersey.api.client.ClientResponse;
  import com.sun.jersey.api.client.WebResource;
  import com.sun.jersey.client.apache.ApacheHttpClientHandler;
  
  HttpClient httpClient = new HttpClient();
  ApacheHttpClientHandler clientHandler = new ApacheHttpClientHandler(httpClient);
  String url = "http://petstore.swagger.wordnik.com:80/api/store/order";
  WebResource.Builder builder = new Client(clientHandler).resource(url).accept("application/json").entity("{}", "application/json");
  ClientResponse clientResponse = null;
  try {
          clientResponse = builder.post(ClientResponse.class);
      } finally {
          if (clientResponse != null) {
              clientResponse.close();
          }
      }
  
  System.out.println("Status: " + clientResponse.getStatus());
  </code></pre>
  
  <p>Error that we receive:</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException code
  at com.sun.jersey.api.client.RequestWriter$RequestEntityWriterImpl.&lt;init&gt;(RequestWriter.java:186)
  at com.sun.jersey.api.client.RequestWriter.getRequestEntityWriter(RequestWriter.java:248)
  at     com.sun.jersey.client.apache.DefaultApacheHttpMethodExecutor.executeMethod(DefaultApacheHttpMethodExecutor.java:121)
  at     com.sun.jersey.client.apache.ApacheHttpClientHandler.handle(ApacheHttpClientHandler.java:175)
  at com.sun.jersey.api.client.Client.handle(Client.java:652)
  at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682)
  at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
  at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:560)
  </code></pre>
  
  <p>If we change the client creation from new Client(clientHandler) to just new Client() then we get the expected response 200.</p>
  
  <p>The jar files that we have in our classpath</p>
  
  <ul>
  <li>commons-httpclient-3.1.jar </li>
  <li>jersey-client-1.18.jar</li>
  <li>jersey-apache-client-1.18.jar</li>
  <li>commons-logging-1.0.4.jar</li>
  <li>jersey-core-1.18.jar</li>
  <li>commons-codec-1.2.jar</li>
  </ul>
  
  <p>Does anyone have faced the similar issue and know the resolution of this problem?</p>