Alexander Litus Alexander Litus - 2 months ago 17
Java Question

GAE Datastore - cannot start LocalDevelopmentDatastore programmatically on Windows

Environment:

Java API

google-api-services-datastore-protobuf v1beta2-rev1-3.0.0
.

OS: Windows 7.

Goal:

Start Local Datastore Server using the method:

public void start(String sdkPath, String dataset, String cmdLineOptions)


from
com.google.api.services.datastore.client.LocalDevelopmentDatastore.java
in order to use it in unit tests.

Steps:

I downloaded gcd tool
gcd-v1beta2-rev1-3.0.2.zip
and put it to
C:\gcd
folder

(paths to
gcd.cmd
and
gcd.sh
are `C:\gcd).
Also, I set environment variables:

"DATASTORE_HOST"="http://localhost:8080" and
"DATASTORE_DATASET"="myapp".


Problem:


LocalDevelopmentDatastoreException occurs.

Caused by: java.io.IOException: Cannot run program "./gcd.sh" (in directory "C:\gcd"): CreateProcess error=2, The system cannot find the file specified.


Note that it tries to find
./gcd.sh
but not
gcd.cmd
.

Java code:

String datasetName = "myapp";
String hostName = "http://localhost:8080";

DatastoreOptions options = new DatastoreOptions.Builder()
.host(hostName)
.dataset(datasetName).build();

LocalDevelopmentDatastoreOptions localOptions = new LocalDevelopmentDatastoreOptions.Builder()
.addEnvVar("DATASTORE_HOST", hostName)
.addEnvVar("DATASTORE_DATASET", datasetName).build();

LocalDevelopmentDatastore datastore = LocalDevelopmentDatastoreFactory.get().create(options, localOptions);

datastore.start("C:\\gcd", datasetName);


This code is based on the example from LocalDevelopmentDatastore.java documentation.

Please help.

Answer

It seems as though the method is only programmed to look for gcd.sh, as it doesn't appear there's anything in your config which could have helped this to not fail. I suggest you open a defect report in the Cloud Platform Public Issue Tracker.