November Happy Hour will be moved to Thursday December 5th.

EPiServer Scheduled job not running for scheduled time. Only running for StartMannually

Vote:
 

Hi I have created a  sample scheduled job with code

using System;

using EPiServer;

using EPiServer.plugIn;

namespace development{

 [EPiServer.plugIn.ScheduledPlugIn(displayname="Samplescheduler")]

public class samplescheduler

{

public samplescheduler()

{}

public static string Execute()

{

return System.DateTime.Now.ToString(); 

}

}

}

}

 

I am able to debug this by clicking on "StartMannually" button. But not for the scheduled time. And for the scheduled time it is failing and giving message as "Object reference not set to an instance of an object".

Can anybody help me in this . Do I need to do any settings.

 

#19722
Apr 30, 2008 9:41
Vote:
 

If a scheduled job works when run manually but fails with exceptions when runned through scheduler the most likely cause is that code assumes an HttpContext.Current to be present.

Note that when running from the scheduler, there will be no HttpContext.Current available.

If your scheduled job _really_ only consists of the code above, then its a little more mysterious. Make sure that its really *this* job that fails ant not something else.

Regards,
Johan

#19726
Apr 30, 2008 10:50
Vote:
 

Hi

Johan makes some good points. If the code above fails with a NullReferenceException when run scheduled, the problem must be with the scheduler.

First of all, make sure that the EPiServer Scheduler service is up and running without any problems. Also try some of the built in scheduled jobs, are they working when run schduled?

#19727
Apr 30, 2008 11:12
Vote:
 

This is just a sample scheduled job that I have created , As this also gives me same result,  Instead of writing all the code which is in my actual scheduled job.

I tried to create some other jobs also which are available over net. But for all I got the same error. All of them are working for "StartMannually"

 

#19728
Apr 30, 2008 11:19
Vote:
 

All the other scheduled jobs including builtin scheduled jobs are running fine.

When I put a breakpoint at the "Execute" function of the scheduled job  it is not stoping at that for the scheduled time though visual studio is in Run mode. It is stoping there only for "StartMannually".

I am using visual studio 2003 and EPiServer 4.

Please suggest me some solution,

#19730
Apr 30, 2008 12:47
Vote:
 

If the debugger stops on a job executed by start manually you have attached the debugger to the web-process.

If you want to debug something executed from the scheduler you must attach the debugger to the scheduler-process.

#20339
May 27, 2008 15:13
Vote:
 

Not entirely true, the job will still be executed within the context of the webapplication.

The schedulerprocess is just keeping track of *what* job and *when* to execute; the "execution" is then runned inside the webapplication.

If you are unable to hit your breakpoint when running through the scheduler, the problem must be a crash *before* youre jobs Execute() method is called, possibly inside the scheduler code itself.

The reason I asked if the initially posted code *really* was all the jobs code consisted of was that it doesnt seem syntactically correct; theres one rightbracket ( '}' ) too many at the end to satisfy the compiler.

Now this could of course be due to a slip on the keyboard when submitting the post, but if code was copied and pasted, then perhaps some crucial parts were left out?

Regards,
Johan Olofsson

#20383
May 27, 2008 21:52
Vote:
 
If the scheduler runs the job, you must attach to the scheduler.
#20386
May 27, 2008 22:39
Vote:
 

The schedulersvc process doesnt run the job - it triggers its execution through remoting into the webapplications context. The job is then executed within the webapplication.

/johan

#20387
May 27, 2008 23:24
Vote:
 

I am able to run the scheduled job for the scheduled time, But very often it is succesful.

 When I left the scheduled job running for al long time with specific intervels set for Next scheduled date and time.

Randomly it is failing.

Some times throwing error as

 "Object reference not set to an instance of an object"

and some times

"Exception has been thrown by the target of an invocation.[The source was not found, but some are all event logs could not be searched. Inaccessable logs:Security.]

The same code is successfull some times.

Can any body please let me know the reason for this.

 

 

#23665
Sep 12, 2008 8:34
Vote:
 

Is the site running on several servers/development machines with one shared database?

#23668
Sep 12, 2008 9:36
Vote:
 

Hi Erik,

Yes you are correct our site is running on several servers and developers from onsite and offshore are using a common database on different server.

Is this a problem?

#23677
Sep 12, 2008 14:10
Vote:
 

I have the same problem, does anyone solve this?

That will save a lot of my time.

#69609
Mar 29, 2013 5:31
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.