GAE-使用cron计划任务(java)时无法上传cron.xml,500错误

错误信息

com.google.appengine.tools.admin.AdminException: Unable to update app: Error posting to URL: https://appengine.google.com/api/datastore/cron/update?app_id=fatkuns&version=4&
500 Internal Server Error

Server Error (500)
A server error has occurred.

at com.google.appengine.tools.admin.AppAdminImpl.update(AppAdminImpl.java:62)

at com.google.appengine.eclipse.core.proxy.AppEngineBridgeImpl.deploy(AppEngineBridgeImpl.java:271)

at com.google.appengine.eclipse.core.deploy.DeployProjectJob.runInWorkspace(DeployProjectJob.java:145)

at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)

at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Caused by: java.io.IOException: Error posting to URL: https://appengine.google.com/api/datastore/cron/update?app_id=fatkuns&version=4&
500 Internal Server Error

Server Error (500)
A server error has occurred.

at com.google.appengine.tools.admin.ServerConnection.send(ServerConnection.java:149)

at com.google.appengine.tools.admin.ServerConnection.post(ServerConnection.java:82)

at com.google.appengine.tools.admin.AppVersionUpload.send(AppVersionUpload.java:559)

at com.google.appengine.tools.admin.AppVersionUpload.updateCron(AppVersionUpload.java:260)

at com.google.appengine.tools.admin.AppVersionUpload.doUpload(AppVersionUpload.java:133)

at com.google.appengine.tools.admin.AppAdminImpl.update(AppAdminImpl.java:56)

… 4 more

原因:

cron.xml文件书写不正确

记得<timezone>Asia/Shanghai</timezone>这个是必须写的,不然无法上传,官方的例子居然有一个没写

<?xml version=”1.0″ encoding=”UTF-8″?>

<cronentries>

<cron>

<url>/cron</url>

<description>描述</description>

<schedule>every 2 minutes</schedule>

<timezone>Asia/Shanghai</timezone>

</cron>

</cronentries>

<?xml version=”1.0″ encoding=”UTF-8″?>
<cronentries>
<cron>
<url>/cron</url>
<description>描述</description>
<schedule>every 2 minutes</schedule>
<timezone>Asia/Shanghai</timezone>
</cron>
</cronentries>

更新:发现如果 url填写错误也会上传失败,正确的方式是写“/xxxx”这样的路径,不能写全路径..




fatkun

5条评论

看文档就找得到了,看你博文你也已经知道了。

要删除所有 cron job,请将 cron.xml 文件更改为只包含以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<cronentries/>

发表评论

电子邮件地址不会被公开。