James Ridey
James Ridey

Reputation: 21

IllegalStateException with Google App Engine Local Datastore

So I'm trying to run a Google App Engine with the Datastore locally to test and debug. The local App Engine seems to work on its own, as does the datastore emulator.

But as soon as I set the environment variables for the datastore emulator, and restart the local App Engine, it crashes with the error,

Caused by: java.lang.IllegalStateException: Must use project ID as app ID if project ID is provided. 

I've attached a more complete stack trace below

From the error message, I suspected I need to change my project id to the project name instead. So I tried replacing various instances of the project id with the project name where I could and unfortunately this did not work either.

Commands I'm running:

1. gcloud config set project PROJECT-ID
2. export ENDPOINTS_SERVICE_NAME=name.endpoints.PROJECT-ID.cloud.goog
3. gcloud beta emulators datastore start
4. $(gcloud beta emulators datastore env-init)
5. mvn appengine:run

I've put the stack trace on pastebin https://pastebin.com/atcnYwrq

Upvotes: 2

Views: 1072

Answers (2)

Steve Ferguson
Steve Ferguson

Reputation: 121

I happened to stumble into a way to fix this.

export DATASTORE_USE_PROJECT_ID_AS_APP_ID=true

Upvotes: 12

James Ridey
James Ridey

Reputation: 21

If anyone else stumbles into this error, I haven't fixed the original error but if you use the Remote API instead, it seems to setup a local datastore when RemoteCheck is false.

If you are using Objectify then you will need to use Remotely, setup the CustomFactory and register it and make sure you have something like the following in your web.xml

<filter-mapping>
    <filter-name>ObjectifyFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>
<listener>
    <listener-class>com.packagename.OfyHelper</listener-class>
</listener>

Upvotes: 0

Related Questions