Scheduler Job - When clicked [Start Manually] works fine based on the functionality. The same job throws exception [Exception has been thrown by the target of an invocation. [Object reference not set to an instance of an object.]] when it is invoked automatically based on the frequency settings. Moreover we are not able to attach the debug process on the automatic mode. Other EPIServer Scheduler Jobs are working fine on the automatic mode.
A common misstake is the use of HttpContext in schduled jobs. Another is trying the fetch pages that the scheduler doen't have access to.
We had issues with scheduler when run under the auto and manual modes. In auto mode, it runs as an anonymous user, whereas when run manually, it runs as the person who started the process. We found that even things like date formatting were going askew between the two and so any downstream processinng did not get valid data and threw exceptions.
Only piece of advice I can give is step through the code. Sorry.
Hi, as add on to the issue description. (Working same team as Santosh). We observe that sample job given by EPiServer (such as EPiServer.SubscriptionJob) is running normal and successful in the scheduler while our customize job will throw error "Object reference not set to an instance of an object" or "Exception been thrown by the target of invocation". Will that due to some environment setting that need to be done before running a job? Or is it any rights issue? Sort of can't figure it out since even in debugger mode the code is not being executed.
There is no configuration that needs to be done to get the scheduled jobs to run. There must be something in the code that is causing the NullReferenceException.
Santosh, you said you had a simple job that caused the error. Could you perhaps post the code so we can take a look at it. Hopefully that can give us some clues as to why the error is occuring.
Per GunsarfsEPiServer CMS Development Team
I too faced the same problem some time back to execute a simple job like just displaying a string. It was running mannually all the time , and for the scheduled time throwing error as above. But when I left the job running for a long time, surprisingly for some times I found it was sucess full when I checked in the history tab. I am not able to figure out the reasons why it was failed and why some times it was successfull. Some times I am able to debug also. Some times not at all coming in to the code. Running some where outside and throwing error as "Object reference not set to an instance of an object".
Can any body give me correct reason for this. So that it would be very much help ful for me.