I have a cron job that I want to run that calculates a popularity rating using the Entities in my Cloud Datastore.
Entity Excerpt:
@Entity
public class Theme {
@Id
private String themeID;
public int popularity;
public void setPopularity(int popularity) {
this.popularity = popularity;
}
Inside my 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");
}
}
I know the cron job runs as required because if I change "101" to (long) 101 it fails stating a String is required in the log however if coded as above, the log file gives the following:
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 can't figure out how to make it log an error to tell me why the Entity "101" doesn't have a popularity value of 3 after this cron job runs. How can I debug this?
On a side note, the log files don't show "Cron Job has been executed" either... I am using the following website as a tutorial here