title: Google dataflow - Connecting to datastore using datastore options gives error
body: <p>We are trying to connect to datastore services through a dataflow job written in java but we are facing issues due to datastore SDK error.</p>
  
  <p>We are running the job with directrunner on local machine using eclipse.</p>
  
  <p>Code:</p>
  
  <pre><code>import java.net.SocketTimeoutException;
  
  import org.apache.beam.sdk.options.PipelineOptions;
  
  import com.google.cloud.datastore.Datastore;
  import com.google.cloud.datastore.DatastoreOptions;
  
  public class StarterPipeline {
  
      public interface StarterPipelineOption extends PipelineOptions {
  
      }
  
      @SuppressWarnings("serial")
      public static void main(String[] args) throws SocketTimeoutException {
  
          Datastore datastore = DatastoreOptions.getDefaultInstance().getService();
  
      }
  }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalArgumentException: java.net.URISyntaxException: Illegal character in path at index 45: https://datastore.googleapis.com/v1/projects/&lt;!DOCTYPE html&gt;
  at com.google.datastore.v1.client.DatastoreFactory.validateUrl(DatastoreFactory.java:122)
  at com.google.datastore.v1.client.DatastoreFactory.buildProjectEndpoint(DatastoreFactory.java:108)
  at com.google.datastore.v1.client.DatastoreFactory.newRemoteRpc(DatastoreFactory.java:115)
  at com.google.datastore.v1.client.DatastoreFactory.create(DatastoreFactory.java:65)
  at com.google.cloud.datastore.spi.v1.HttpDatastoreRpc.&lt;init&gt;(HttpDatastoreRpc.java:71)
  at com.google.cloud.datastore.DatastoreOptions$DefaultDatastoreRpcFactory.create(DatastoreOptions.java:61)
  at com.google.cloud.datastore.DatastoreOptions$DefaultDatastoreRpcFactory.create(DatastoreOptions.java:55)
  at com.google.cloud.ServiceOptions.getRpc(ServiceOptions.java:512)
  at com.google.cloud.datastore.DatastoreOptions.getDatastoreRpcV1(DatastoreOptions.java:179)
  at com.google.cloud.datastore.DatastoreImpl.&lt;init&gt;(DatastoreImpl.java:56)
  at com.google.cloud.datastore.DatastoreOptions$DefaultDatastoreFactory.create(DatastoreOptions.java:51)
  at com.google.cloud.datastore.DatastoreOptions$DefaultDatastoreFactory.create(DatastoreOptions.java:45)
  at com.google.cloud.ServiceOptions.getService(ServiceOptions.java:499)
  at purplle.datapipeline.StarterPipeline.main(StarterPipeline.java:234)
  Caused by: java.net.URISyntaxException: Illegal character in path at index 45: https://datastore.googleapis.com/v1/projects/&lt;!DOCTYPE html&gt;
  at java.net.URI$Parser.fail(Unknown Source)
  at java.net.URI$Parser.checkChars(Unknown Source)
  at java.net.URI$Parser.parseHierarchical(Unknown Source)
  at java.net.URI$Parser.parse(Unknown Source)
  at java.net.URI.&lt;init&gt;(Unknown Source)
  at com.google.datastore.v1.client.DatastoreFactory.validateUrl(DatastoreFactory.java:120)
  ... 13 more
  </code></pre>
  
  <p>We are using below versions of SDKs which i believe are upto date.</p>
  
  <pre><code>&lt;!-- https://mvnrepository.com/artifact/com.google.cloud/google-cloud-storage --&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;com.google.cloud&lt;/groupId&gt;
      &lt;artifactId&gt;google-cloud-storage&lt;/artifactId&gt;
      &lt;version&gt;1.37.1&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;!-- https://mvnrepository.com/artifact/com.google.cloud/google-cloud-datastore --&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;com.google.cloud&lt;/groupId&gt;
      &lt;artifactId&gt;google-cloud-datastore&lt;/artifactId&gt;
      &lt;version&gt;1.37.1&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
      &lt;groupId&gt;com.google.cloud.dataflow&lt;/groupId&gt;
      &lt;artifactId&gt;google-cloud-dataflow-java-sdk-all&lt;/artifactId&gt;
      &lt;version&gt;2.5.0&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>While going across google for solution we found below thread which states this issue has been fixed in February but im facing this issue.</p>
  
  <p><a href="https://github.com/GoogleCloudPlatform/google-cloud-java/issues/2440" rel="nofollow noreferrer">https://github.com/GoogleCloudPlatform/google-cloud-java/issues/2440</a></p>