I have a simple test cron job which does not succeed in running on GAE. The target url runs correctly when invoked from a browser (when I’m logged in as admin), but cron is not successfully running the job. The GAE Cron Jobs page shows:
/admin/cron/crontest1 every 2 hours (America/New_York)
Initial simple test 2015/06/28 23:18:03 2 secs late Failed
Here’s the cron.xml:
<?xml version="1.0" encoding="UTF-8"?>
<cronentries>
<cron>
<description>Initial simple test</description>
<timezone>America/New_York</timezone>
<url>/admin/cron/crontest1/</url>
<schedule>every 2 hours</schedule>
</cron>
</cronentries>
In web.xml, the <url-pattern>/admin/*</url-pattern> gets the <security-constraint>:
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
The target url /admin/cron/crontest1/ assembles a very simple jsp page equivalent to:
<head>
<script type='text/javascript' src='/admin/cron/crontest1/crontest1.js'></script>
<script>
$(document).ready(function() {
crontest1init();
});
</script>
</head>
<body>
<h1>CronTest1</h1>
</body>
where crontest1.js is just:
function crontest1init()
{
AdminIntf.crontest1();
}
And AdminIntf.crontest1() is just a DWR (Direct Web Remoting) call to this:
public static void crontest1(){
final DateTimeFormatter fmt = Constants.YMDHMS_DATETIME_FORMATTER;
String now = fmt.print(System.currentTimeMillis());
logger.warn("############## crontest1() ############: " + now);
}
When I am logged in as admin and issue the url
the result is a page showing
CronTest1
and the logs show:
……/dwr/call/plaincall/AdminIntf.crontest1.dwr 200 …blah,blah
I 2015-06-28 21:10:18.026 org.directwebremoting.util.CommonsLoggingOutput info: Exec: AdminIntf.crontest1()
W 2015-06-28 21:10:18.064 com.strongbrain.admin.AdminIntf crontest1: ############## crontest1() ############: 2015-06-29 03:10:18 UTC
The url action returns 200, but, as noted at top, cron doesn’t successfully run this. Clearly I’m missing something essential, but I can’t see what.
Any help will definitely be appreciated.
Thanks in advance,
Ken Bowen