I have a custom SharePoint 2010 Timer Job that had been running fine. The job performs processing on 88 sites in our web application. One day, everything was working fine. The next day, the 72nd site started throwing the following error:
OWSTIMER.EXE Critical
The Execute method of job definition MyNamespace.Administration.RequestJobDefinition threw an exception. More information is included below. Object reference not set to an instance of an object.OWSTIMER.EXE Unexpected
Exception stack trace: at Microsoft.SharePoint.SPSite.PreinitializeServer(SPRequest request) at Microsoft.SharePoint.SPWeb.InitializeSPRequest() at Microsoft.SharePoint.SPListCollection.EnsureListsData(Guid webId, String strListName) at Microsoft.SharePoint.SPListCollection.GetListByName(String strListName, Boolean bThrowException) at MyNamespace.MyJobs.MyJobBase.Process(SPSite site) at MyNamespace.MyJobs.MyJobBase.Process(Guid id) at MyNamespace.MyJobs.MyJobBase.Process(List`1 siteIDs) at MyNamespace.Administration.RequestJobDefinition.Execute(Guid targetInstanceId) at Microsoft.SharePoint.Administration.SPTimerJobInvokeInternal.Invoke(SPJobDefinition jd, Guid targetInstanceId, Boolean isTimerService, Int32& result)
Here is the code that is failing:
protected virtual bool Process(SPSite site)
{
bool proceed = true;
SPList list = site.RootWeb.Lists.TryGetList("My Messages");
if (list != null)
{
proceed = Process(list);
}
return proceed;
}
The error is happening on TryGetList, which is strange because not only does the list exist, but that method is not supposed to return an exception.
I have not had any recent deployments. But even in the latest deployments, the above code has not changed in well over a year.
What could be going wrong?
site
andsite.RootWeb
are not null at that point?