Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java KeyFactory.stringToKey()始终提供;IllegalArgumentException:无法分析引用;_Java_Google App Engine - Fatal编程技术网

Java KeyFactory.stringToKey()始终提供;IllegalArgumentException:无法分析引用;

Java KeyFactory.stringToKey()始终提供;IllegalArgumentException:无法分析引用;,java,google-app-engine,Java,Google App Engine,我制作了一个小的谷歌应用程序引擎程序,它突然给出了我不理解的异常。在本地运行此程序时,我尝试在许多字符串上使用KeyFactory类的Google App Engine SDK stringToKey()方法,但这始终会给我一个错误 示例: KeyFactory.stringToKey("randomstring"); 这两行代码都给出了以下IllegalArgumentException: java.lang.IllegalArgumentException: Could not parse

我制作了一个小的谷歌应用程序引擎程序,它突然给出了我不理解的异常。在本地运行此程序时,我尝试在许多字符串上使用KeyFactory类的Google App Engine SDK stringToKey()方法,但这始终会给我一个错误

示例:

KeyFactory.stringToKey("randomstring");
这两行代码都给出了以下IllegalArgumentException:

java.lang.IllegalArgumentException: Could not parse Reference
at com.google.appengine.api.datastore.KeyFactory.stringToKey(KeyFactory.java:203)
at com.businessLayer.DDOSLogAnalyser.handleUsersSet(DDOSLogAnalyser.java:81)
at com.businessLayer.DDOSLogAnalyser.doPost(DDOSLogAnalyser.java:50)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[...]
使用DDOSLogAnalyser是我自己编写的唯一类。该类扩展了HttpServlet超类。如果需要更多信息,我很乐意提供。

“randomstring”不是有效的键字符串。我认为有效密钥字符串的格式应如下所示:

Key([Key("ancestorKindName", idOrName),] "kindName", idOrName)

请注意,
stringToKey
方法并不打算以分配的方式创建密钥。如果您正在寻找此类功能,请在中查找
DatastoreService.allocateIds()

请访问likn下方,这可能会很有用