Cron doesn't start

87 views
Skip to first unread message

Shachar Grembek

unread,
May 31, 2017, 6:35:41 PM5/31/17
to Google App Engine
Hi,

I am running an App Engine Standard environment and trying to se cron scheduled tasks. I've created the cron.xml (alongside the web.xml) and went by the guide in the following link: https://cloud.google.com/appengine/docs/standard/java/config/cron
However, I don't see the cron start (both in the logs and in the console App Engine -> Task Queues -> Cron Jobs)

Can u please advise what might I be doing wrong?

cron.xml:
<?xml version="1.0" encoding="UTF-8"?>
<cronentries>
<cron>
<url>/tasks/repsai/retrieve_tickets</url>
<target>beta</target>
<description>daily summary job</description>
<schedule>every 2 minutes</schedule>
</cron>
<cron>
<url>/recache</url>
<description>Repopulate the cache every 2 minutes</description>
<schedule>every 2 minutes</schedule>
</cron>
</cronentries>

Thanks

Roxana Ioana Roman

unread,
Jun 1, 2017, 9:29:39 AM6/1/17
to Google App Engine
Are your cron jobs visible in App Engine -> Task Queues -> Cron Jobs? If not, you have to run update_cron. 
Can you add your web.xml and the Servlet which handles these cron jobs? Your second cron job does not have a <target> which means the job will run on the default service .

Roxana

Shachar Grembek

unread,
Jun 1, 2017, 9:35:38 AM6/1/17
to Google App Engine
Hi Roxana,

Thanks, I cannot see the cron jobs App Engine -> Task Queues -> Cron Jobs.  How do I run update_cron?

Please find the web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<servlet>
<servlet-name>repsai-tickets-retrieval</servlet-name>
<servlet-class>ai.reps.server.api.RepsAITicketsRetrieval</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>repsai-tickets-retrieval</servlet-name>
<url-pattern>/tasks/repsai/retrieve_tickets</url-pattern>
</servlet-mapping>

<filter>
<filter-name>ObjectifyFilter</filter-name>
<filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ObjectifyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>ai.reps.server.datalayer.OfyHelper</listener-class>
</listener>
</web-app>

Roxana Ioana Roman

unread,
Jun 1, 2017, 10:27:04 AM6/1/17
to Google App Engine
To update cron: 

./appengine-java-sdk/bin/appcfg.sh update_cron [YOUR_APP_DIR]

If you are using maven you can also do inside your project directory:
mvn appengine update_cron

After this you should be able to see a list of your cron jobs under App Engine -> Task Queues -> Cron Jobs and you will also be able to start them manually from there.

Also, in the web.xml there is no mapping for /recache url. 
A cron job invokes an URL, using an HTTP GET request, so make sure you have a doGet () method in your RepsAITicketsRetrieval class.

Shachar Grembek

unread,
Jun 1, 2017, 10:42:53 AM6/1/17
to Google App Engine
Hi,

Thanks, We are progressing, but only this time I received the following error when running update_cron:
"Bad configuration: Could not find the WEB-INF directory in /Users/shachar/server_project/WEB-INF. The given application file path must point to an exploded WAR directory that contains a WEB-INF directory."

The WEB-INF is located in the folder web within my project /Users/shachar/server_project/web/WEB-INF, how can I tell update_cron where is the right folder?

Best
Shachar

Roxana Ioana Roman

unread,
Jun 1, 2017, 4:28:27 PM6/1/17
to Google App Engine
Hi,
appcfg.sh update_cron [YOUR_APP_DIR]. Try playing with  [YOUR_APP_DIR], give it /Users/shachar/server_project/web or move WEB-INF one step before. My WEB-INF is in src/main/webapp/ WEB-INF.

Good luck!

Shachar Grembek

unread,
Jun 4, 2017, 4:04:00 AM6/4/17
to Google App Engine
Worked! Thanks
Reply all
Reply to author
Forward
0 new messages