title: JavaFX UI freezes on web service call
body: <p>I have a JavaFX application that consumes web services via Jersey Client API, every once in a while parts of the application(screens) freeze while executing a call to a web service.</p>
  
  <p>There is no thread that i used to make the web service calls.</p>
  
  <p>The following is the Jersey Client Code:</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.api.client.config.ClientConfig;
  import com.sun.jersey.api.client.config.DefaultClientConfig;
  import com.sun.jersey.api.json.JSONConfiguration;
      public class WSClient{
          WebResource webResource;
          ClientResponse response;
  
          protected Client getWSClient() {
  
              ClientConfig clientConfig = new DefaultClientConfig();
  
              clientConfig.getFeatures().put(
                      JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
  
              Client wsClient = Client.create(clientConfig);
              return wsClient;
          }
  
          public ArrayList&lt;String&gt; getNames(){
              ArrayList&lt;String&gt; names= new ArrayList&lt;&gt;();
  
              try{
                  webResource = getWSClient().resource("http://localhost:8080/names");
                  response = webResource.type("application/json").accept("application/json").get(ClientResponse.class);
  
              }catch(Exception ex){
                  log.error("Failed : " + ex.getMessage());
                  return null;
              }
              if(response.getStatus() != 200){
                  return null;
              }
              String output = response.getEntity(String.class);
              names= getGson().fromJson(output,
                      new TypeToken&lt;ArrayList&lt;String&gt;&gt;() {
                      }.getType());
  
  
  
              return names;
          }
      }
  </code></pre>
  
  <p>The Following is the JavaFX controller class:</p>
  
  <pre><code>private ComboBox&lt;String&gt; cmbNames = new ComboBox&lt;&gt;();
  
  cmbNames.setItems(FXCollections.observableList(new WSClient().getNames()));
  </code></pre>
  
  <p>your help is really appreciated!</p>