我是 appEngine 的新手,我尝试了我的项目所必需的简单事情:我创建了简单的 JDO 图像类:
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Image {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
private Blob image;
@Persistent
private String type;
@Persistent
private String description;
public Key getKey() {
return key;
}
public void setKey(Key key) {
this.key = key;
}
public Blob getImage() {
return image;
}
public void setImage(URL url) throws IOException {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
url.openStream()));
String line;
StringBuffer stbf = new StringBuffer();
while ((line = reader.readLine()) != null) {
stbf.append(line);
}
image = new Blob(stbf.toString().getBytes());
reader.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
成功创建并部署到 AppEngine 的端点。当我尝试通过 google-api-explorer https://developers.google.com/apis-explorer/?base=https://my-application.appspot.com/_ah/api#s/将简单对象插入数据存储区时,仅使用 id 和 appID 参数链接到图像和密钥,我收到以下错误:
503 Service Unavailable
- Show headers -
{
"error": {
"errors": [
{
"domain": "global",
"reason": "backendError",
"message": "java.lang.NullPointerException"
}
],
"code": 503,
"message": "java.lang.NullPointerException"
}
}
当我将键从 Long 类型更改为 by 时,查询正确执行,并且我在数据存储区中看到了新实体。
除此之外,在文档中说“如果编码的键字段为空,则在保存对象时该字段将填充系统生成的键”。但似乎没有钥匙就不能接受?
有人可以帮我解决这个问题吗?