title: javax.ws.rs.ProcessingException while sending request through Jersey
body: <p>I am trying to send a JSON request to a secure REST webservice using a keystore file and I am using Jersey API. Below is the snippet of my code</p>
  
  <pre><code>SslConfigurator sslConfigurator = SslConfigurator.newInstance().trustStoreFile("C:\\Users\\******\\test.keystore").trustStorePassword("password");
  SSLContext sslContext = sslConfigurator.createSSLContext();
  Client client = ClientBuilder.newBuilder().sslContext(sslContext).build();
  WebTarget target = client.target("https://hostname:portnumber").path("resourse/methodname/v1");
  
  Form form = new Form();
  form.param("key1", "value1");
  form.param("key2", "value2");
  
  Response response = target.request(MediaType.APPLICATION_JSON_TYPE).post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE));
  System.out.println(response);
  </code></pre>
  
  <p>But I am getting the following exception on the last but one line. </p>
  
  <pre><code>Exception in thread "main" javax.ws.rs.ProcessingException: Already connected
  at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:264)
  at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:684)
  at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:681)
  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:444)
  at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:681)
  at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:437)
  at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:343)
  at TestMain.main(TestMain.java:29)
  Caused by: java.lang.IllegalStateException: Already connected
  at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnection.java:3014)
  at sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestProperty(HttpsURLConnectionImpl.java:316)
  at org.glassfish.jersey.client.internal.HttpUrlConnector.setOutboundHeaders(HttpUrlConnector.java:421)
  at org.glassfish.jersey.client.internal.HttpUrlConnector.access$100(HttpUrlConnector.java:96)
  at org.glassfish.jersey.client.internal.HttpUrlConnector$4.getOutputStream(HttpUrlConnector.java:384)
  at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:200)
  at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:194)
  at org.glassfish.jersey.message.internal.CommittingOutputStream.commit(CommittingOutputStream.java:262)
  at org.glassfish.jersey.message.internal.OutboundMessageContext.commitStream(OutboundMessageContext.java:816)
  at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:545)
  at org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:388)
  at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:285)
  at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:255)
  ... 10 more
  </code></pre>