Timer job errors and solutions in SharePoint

Timer job errors and solutions in SharePoint
5 votes, 4.60 avg. rating (91% score)

Introduction

In this post we will see what the various errors that come while handling Timer Job in SharePoint.
These errors are sometime common for many developers but could take time to resolve. Hope this will resolve your errors and save your time.
Don’t miss the article how to create Timer job for specific site in SharePoint

What are the points that are covered

  • Frequent errors that come up with Timer job and their resolution

Error: Access denied while creating/deleting the Timer job from the feature

We may encounter the following error while activating the feature from UI and inside the feature activation code we have code to create/delete Timer job


Access denied.
at Microsoft.SharePoint.Administration.SPPersistedObject.Update()
at Microsoft.SharePoint.Administration.SPJobDefinition.Update()
at xxx.xxx.<>c__DisplayClass1.b__0()

Solution

Activate the feature from command prompt rather than from the UI and we won’t be getting the above error
Following is the quick code to activate or deactivate the feature by stsadm


Activating the feature
stsadm -o activatefeature -fileName TimerJobFeatureReceiver\Feature.xml -url http://adicodes/sites/mysite -force

Deactivating the feature
stsadm -o deactivatefeature -fileName TimerJobFeatureReceiver\Feature.xml -url http://adicodes/sites/mysite -force

Error: Timer job running more than once

This is one common error many users face. For example, we have written sending email while Timer job executes. It will be so annoying if users says that they got more than one email with same content and time stamp.

Solution
This duplicate job running behavior is due to the SPJobLockType in the constructor.
Suppose if we are using this constructor

public TimerJob(SPWebApplication webApp): base("TimerJob", webApp, null, SPJobLockType.ContentDatabase)
{
this.Title = "TimerJob";
}

Timer job will execute more than once if the web application for which Timer Job is associated has more than one content database
We can check the number of content databases for the webapplication from central admin site
Go to http://centraladminurl/_admin/CNTDBADM.aspx. Select the webapplication and we can check the number of content databases associated with it

Change the SPJobLockType enumerator value from ContentDatabase to Job in the constructor as follows

public TimerJob(SPWebApplication webApp): base("TimerJob", webApp, null, SPJobLockType.Job)
{
this.Title = "TimerJob";
}


Now, the Timer job will execute only once though there are multiple content databases associated

You can check what the SPJobLockType enumeration is for at
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spjoblocktype.aspx

Error: Latest code is not running after Timer job is deployed

This is also one common error many users face. They get surprised why the latest deployed Timer job code is not running and sometimes get the
following error

OWSTIMER.EXE (0x0AAC) 0x0BF0 Windows SharePoint Services Topology 7i0u High SharePoint cannot deserialize an object of type Pages.SurveySiteEmailJob, Pages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c475c2fd38120dac on this machine.
This typically occurs because the assembly containing this type is not installed on this machine.
In this case, this message can be safely ignored. Otherwise, the assembly needs to be installed on this machine in a location that can be discovered by the .NET Framework.

Solution

Just restart the timer service
How to restart the Timer job service in SharePoint 2010

Go to Start > Run (Windows Key+R)
Type Services.msc and hit enter or click on OK.
Under services locate “SharePoint 2010 Timer”.
Stop and Start service

or
with command line code
net stop “SharePoint 2010 Timer”
net start “SharePoint 2010 Timer”

How to restart the Timer job service in SharePoint 2007
Go to Start > Run (Windows Key+R)
Type Services.msc and hit enter or click on OK.
Under services locate “Windows SharePoint Services Timer”.
Stop and Start service
or
with command line code
net stop “Windows SharePoint Services Timer”
net start “Windows SharePoint Services Timer”

Conclusion

We might have tried a lot for figuring out what is the cause of the error. Hope the the above resolutions will save your time.
You can add up some more bugs if you encounter, so that it will be helpful for any SharePointers :)

June 21, 2012 · Adi · 2 Comments
Tags: ,  · Posted in: Sharepoint 2007, Sharepoint 2010

2 Responses

  1. Piyush - August 30, 2014

    Worked for me Thanks

  2. Roger Ospina - September 10, 2014

    Hello friend, I really appreciate your info. It helped me so much.

    Could you help with something that it’s killing me. I created a timer job but it doesn’t show in the job definitions of central administration.
    I have created the timer job so so so many times, with diferents names, and step to step for verify that i am doing well the code and the process. The feature does show in the features of the web application, and I active it, manually, and even for powershell, i restarted the timer service, i restarted the iis, even the server jajaja……

    I don’t know what else to do …

    Please could you help me !

    Thanks.

Leave a Reply

What is 6 + 8 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)