tracker issue : CF-4195763

select a category, or use search below
(searches all categories and all time range)
Title:

Application scheduled task event handler "onError" not called

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/AsDesigned

Reporter/Name(from Bugbase): Geoffrey Demoulin / Geoffrey Demoulin (Geoffrey Demoulin)

Created: 10/10/2016

Components: Scheduler

Versions: 2016,11.0

Failure Type:

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Windows 10 64 bit

Vote Count: 0

Problem Description:

When creating a scheduled task with an event handler, errors/exceptions are not triggering the onError method.

Steps to Reproduce:

-> Use the attached project.

1/ Create an event handler component implementing "CFIDE.scheduler.ITaskEventHandler"
2/ Override the "public void function onError(struct context)" function with some logging

Actual Result:

onError doesn't seem to be called

Expected Result:

onError should be called and trace of the error should be logged

Any Workarounds:

None found at the moment

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4195763

Reason:	BugVerified

External Customer Info:
External Company:  
External Customer Name: Geoffrey Demoulin
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

  1. October 10, 2016 00:00:00: 1_taskschedulererror.zip
  2. October 11, 2016 00:00:00: 2_taskschedulererrorV2.zip
  3. October 12, 2016 00:00:00: 3_myApp.log.log

Comments:

Hi Geoffrey , I tried on CF 11,0,10,300066 and it works. Can you tell us which version are you on? Thanks, Suchika.
Comment by Suchika S.
1656 | October 10, 2016 04:16:52 AM GMT
Hi Suchika, I am also using the version 11,0,10,300066 (dev. edition). Have you used the attached project to test the issue? I've attached a V2 since I've noticed that there was some extra invalid code in the first version (bad copy/paste). What I'm expecting when running the project: 1/ A new application scheduled task is added (visible in CF admin) and runs every 10s 2/ In application.log, you should see the following line: "Information","DefaultQuartzScheduler_Worker-2","10/11/16","09:22:10","TESTTASKSCHEDULER","executed {""group"":""DEFAULT"",""task"":""test task"",""mode"":""application""}" 3/ You should also see a line saying "An exception occurred" since there is an exception thrown in the execute function. <- THIS NEVER HAPPENS (to me) Am I dong anything wrong?
Comment by External U.
1657 | October 10, 2016 05:46:33 PM GMT
Hi Geoffrey I was trying to write the logs to a custom log file ,which worked . I will attach the file . But now when I check the application.log there is no line saying that an exception occurred. Hence , moving it ToFix. Thanks, Suchika.
Comment by Suchika S.
1658 | October 12, 2016 02:08:40 AM GMT
Hi Suchika, thank you for your answer. I couldn't even log the exception to a custom log. The code I used is the same as the TestTask.cfc contained in the attached project: component implements="CFIDE.scheduler.ITaskEventHandler" { public boolean function onTaskStart(struct context) { return true; } public void function onTaskEnd(struct context) {} public void function onMisfire(struct context) {} public void function onError(struct context) { writeLog("An exception occurred"); // <-- THIS NEVER HAPPENS writeLog("Exception: #serializejson(context)#", "error", true, "taskscheduler"); // Also tried this, didn't work // I also tried a writeDump to an external html file } public void function execute(struct context) { writelog("executed #serializejson(context)#"); throw("TEST EXCEPTION"); // <-- Not captured in onError writelog("end"); } } The task is registered with: cfschedule(action="update", task="test task", mode="application", crontime="*/10 * * * * ?", eventHandler="TestTask"); According to your previous message, you successfully captured the exception, meaning your onError should have been triggered. Can you advise why mine didn't? Or did I misunderstood your comment? Thank you
Comment by External U.
1659 | October 13, 2016 01:04:17 AM GMT
Hi, running 2016,0,02,299200 and also am not seeing onError execute. I'm running a task at the server level with no URL, so the execute method is called on the handler. To test, I put a cfthrow right in the execute method, can't find the exception logged anywhere, including the file I'm writing to onError. I also noticed onMisfire is not always called, only sometimes, though it should be because I'm running from cfadmin off schedule. onTaskEnd is called, even though there was an error.
Comment by External U.
1660 | October 18, 2016 12:54:48 PM GMT
Hi Geoffrey , Application.cfc has onerror method defined which is supposed to handle application specific error, so flow goes to that function. If this method is removed, onerror of ITaskEventHandler will be invoked. Hence closing the bug. Thanks, Suchika
Comment by Suchika S.
1661 | March 08, 2017 11:46:17 AM GMT