我正在使用本地 App Engine 并且我有一个工作端点,但是当我添加以下 API 时,API Explorer ( https://developers.google.com/apis-explorer/?base=http://localhost: 8888/_ah/api#p/ ) 在 JavaScript 控制台出现未处理的异常时无法加载。
@ApiMethod(name = "getClientByPublicId")
public Client getClientByPublicId(@Named("publicId") String publicId) {
EntityManager mgr = getEntityManager();
Client client = null;
client = mgr.find(Client.class, publicId);
mgr.close();
return client;
}
在 Chrome JavaScript 控制台中,它没有提供任何有用的东西,因为它被最小化了
Uncaught java.lang.NullPointerException
(anonymous function)
(anonymous function)
h
(anonymous function)
F.(anonymous function).z.(anonymous function).z.(anonymous function)
_.T.K.__cb
h
c
整个 API Explorer 页面是空白的。
我已经在调试模式下运行它并在添加的 API 中设置了一个断点,但它没有被触发。
如果我在 加载发现文档http://localhost:8888/_ah/api/discovery/v1/apis/clientendpoint/v1/rest
,它会失败并显示以下响应。
{
"error" : {
"message" : ""
}
}
如果我删除了这个新的 API,它一切正常,尽管没有新的 API。
有谁知道这是什么原因造成的?
更新
我偶然发现Google APIs Explorer 没有从我的应用程序引擎应用程序中找到我可用的 ApiMethod ,听起来可能存在路径冲突,我还不明白,但我现在要尝试解决这个想法.
如果这可能是问题,相关的 API 是
@ApiMethod(name = "getClient")
public Client getClient(@Named("id") Long id) {
EntityManager mgr = getEntityManager();
Client client = null;
try {
client = mgr.find(Client.class, id);
} finally {
mgr.close();
}
return client;
}
除非有人知道不同,否则我会试一试并回答我的问题。