简体   繁体   English

Google App Engine本地数据存储区的IllegalStateException

[英]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. 因此,我正在尝试通过本地Datastore运行Google App Engine进行测试和调试。 The local App Engine seems to work on its own, as does the datastore emulator. 本地App Engine似乎可以独立运行, datastore模拟器也可以运行。

But as soon as I set the environment variables for the datastore emulator, and restart the local App Engine, it crashes with the error, 但是,一旦我为datastore模拟器设置了环境变量,并重新启动了本地App Engine,它就会因错误而崩溃,

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. 从错误消息中,我怀疑我需要将项目ID更改为项目名称。 So I tried replacing various instances of the project id with the project name where I could and unfortunately this did not work either. 因此,我尝试用项目名称替换项目ID的各种实例,但不幸的是,这也无法正常工作。

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 我已经将堆栈跟踪放在pastebin https://pastebin.com/atcnYwrq上

我碰巧发现了一种解决此问题的方法。

export DATASTORE_USE_PROJECT_ID_AS_APP_ID=true

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. 如果其他任何人遇到此错误,我都没有解决原始错误,但是如果您使用Remote API ,则似乎在RemoteCheck为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 如果您使用的客体,那么你将需要使用远程 ,建立了CustomFactory和登记,并确保你有这样的事情在你的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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM