title: Getting error: Error reading entity from input stream
body: <p>I have a Jersey REST client talking to (or at least attempting to talk) with PagerDuty (a RESTful https service). I have my client configured for SSL at that seems to be doing it's stuff correctly.  But when I tried to connect and access a URI, I get the message: <em>Error reading entity from input stream</em> which I presume is on my end, not PagerDuty's.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>import java.security.KeyManagementException;
  import java.security.NoSuchAlgorithmException;
  import java.security.SecureRandom;
  
  import javax.net.ssl.HostnameVerifier;
  import javax.net.ssl.HttpsURLConnection;
  import javax.net.ssl.SSLContext;
  import javax.ws.rs.client.Client;
  import javax.ws.rs.client.ClientBuilder;
  import javax.ws.rs.client.Invocation;
  import javax.ws.rs.client.WebTarget;
  import javax.ws.rs.core.MediaType;
  
  import org.glassfish.jersey.client.ClientResponse;
  
  
  
  
  public class Harvest {
  
      public static void main(String[] args) throws KeyManagementException, 
          NoSuchAlgorithmException, NullPointerException {
  
          SSLContext sslContext = SSLContext.getInstance("SSL");
          HostnameVerifier
             hostnameVerifier=HttpsURLConnection.getDefaultHostnameVerifier();
  
          SecureRandom random = new SecureRandom();
          byte bytes[] = new byte[20];
          random.nextBytes(bytes);
  
          sslContext.init(null, null, random);
  
          Client client = ClientBuilder.newBuilder()
                  .sslContext(sslContext)
                  .hostnameVerifier(hostnameVerifier)
                  .build();
  
  
          WebTarget target = client.target("https://peakhosting.pagerduty.com/api/v1/schedules");
          Invocation.Builder builder;
          builder = target.request();
          builder.header("Authorization", "Token token=&lt;secret&gt;");
          builder.accept(MediaType.APPLICATION_JSON);  
  
  --&gt;     ClientResponse response = builder.accept("application/json").get(ClientResponse.class);
          System.out.println(response.getStatus());
  
          if (response.getStatus() != 200) {
              throw new RuntimeException("Failed : HTTP error code : "
                      + response.getStatus());
          }
  
  
      }
  }
  </code></pre>
  
  <p>Any idea what's going on.  Perhaps the SSL is screwed up and that's the cause of the problem?  In any event, I've put an arrow at the line that generated the exception.  Any help will be most definitely be very appreciated.</p>
  
  <p>Thanks,
  Rob</p>