title: Using destinations in Java EE for SAP Cloud Platform
body: <p>First try: </p>
  
  <pre><code>HttpClient client = HttpClientBuilder.create().build();
  HttpGet request = new HttpGet(url);
  </code></pre>
  
  <p>The URL is a hardcoded String. This way the application works locally using the Tomcat server, but not when running on SAP Cloud Platform. On SCP it will result in <code>Caused by: java.net.ConnectException: Connection timed out (Connection timed out) (local port 53603 to address 0.0.0.0, remote port 443 to address xxx.xxx.xxx.xxx</code>.</p>
  
  <p>Second try:</p>
  
  <pre><code>    Context ctx = new InitialContext();
      HttpDestination destination = (HttpDestination) ctx.lookup("java:comp/env/myDestination");
      HttpClient client = destination.createHttpClient();
  </code></pre>
  
  <p>using web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"&gt;
    &lt;display-name&gt;myApp&lt;/display-name&gt;
    &lt;resource-ref&gt;
      &lt;res-ref-name&gt;myDestination&lt;/res-ref-name&gt;
      &lt;res-type&gt;com.sap.core.connectivity.api.http.HttpDestination&lt;/res-type&gt;
  &lt;/resource-ref&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>In this case the <code>import com.sap.core.connectivity.api.http.HttpDestination;</code> </p>
  
  <pre><code>cannot be resolved and when I run in ton SCP it shows similar errors:
  with root cause java.lang.Error: Unresolved compilation problems: 
  HttpDestination cannot be resolved to a type
  HttpDestination cannot be resolved to a type
  </code></pre>
  
  <p>FYI - Using neo-java-web-sdk-3.66.4.1 in Eclipse Oxygen.</p>
  
  <p>Can you not use hardcoded URLs for an HTTPClient in a servlet?
  How do I solve the <code>com.sap.core.connectivity.api.http.HttpDestination</code> reference issue?
  Can you still test an application locally if the code is using destinations?</p>