0
我有一个我想运行的计划使用我的云数据存储中的实体的人气评级的cron作业。谷歌应用程序引擎Cron作业未更新实体
实体摘录:
@Entity
public class Theme {
@Id
private String themeID;
public int popularity;
public void setPopularity(int popularity) {
this.popularity = popularity;
}
里面我CronController:
@SuppressWarnings("serial")
public class CronController extends HttpServlet {
private static final Logger _logger = Logger.getLogger(CronController.class.getName());
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
try {
_logger.info("Cron Job has been executed");
EntityManager mgr = getEntityManager();
Theme theme = null;
theme = mgr.find(Theme.class, "101");
theme.setPopularity(3);
}
catch (Exception ex) {
//Log any exceptions in your Cron Job
_logger.info("error");
}
}
我知道的,因为所需的cron作业运行,如果我改变 “101” 到(长)101失败,说明一个String但是如果如上所述编码,日志文件给出以下内容:
0.1.0.1 - - [19/Feb/2014:17:38:37 -0800] "GET /cron/popularity HTTP/1.1" 200 0 - "AppEngine-Google; (+http://code.google.com/appengine)" "themeviewer.appspot.com" ms=14 cpu_ms=233 queue_name=__cron task_name=243a771773a2bbc80eed32256a5b5043 app_engine_release=1.9.0 instance=00c61b117cabbfbf9dcbf5dedbeb449cc73567
I无法弄清楚如何让它记录一个错误,告诉我为什么实体“101”在这个cron作业运行后没有受欢迎程度值3。我怎样才能调试呢?
在一个侧面说明,日志文件没有显示出“定时任务已执行”要么...我使用以下网站作为一个教程here
工作表示感谢。我以为我之前没有使用过.persist就完成了它。另外,我确实有mgr.close(),但没有在上面的代码中...谢谢! – easycheese