Unexpected System.NullReferenceException After Restoring a SharePoint 2010 Content Database
February 6, 2012 9 Comments
After a user deleted lots of permissions on a SharePoint site we decided to ask for a restore of the content database in order to solve the issue.
Everything was fine, we had all the backups, we knew the time the user deleted the permission assignments and the had the downtime window to restore the backup.
The restore process went fast and fine, the database has been restored and I attached it back to SharePoint.
I tested the site on one of the WFE servers and it looked great, but when I went to the second load balanced server I got the following error message:
Unexpected System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.SharePoint.SPSite.PreinitializeServer(SPRequest request)
at Microsoft.SharePoint.WebControls.SPControl.EnsureSPWebRequest(SPWeb web)
at Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSPControl(HttpContext context)
at Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.GetContextWeb(HttpContext context)
at Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.PostResolveRequestCacheHandler(Object oSender, EventArgs ea)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& complet…
It didn’t make any sense. Why only one of the servers was not working?
I tried the regular debug approach but none of the actions worked:
- Restart the application pool.
- Reboot the server.
- Attach and dettach the content database.
I also tried to connect to the SPWeb using Powershell and it worked on one server and didn’t work on the other one.
I went then to Google to research a little bit and after several false positive articles, I found this article explaining the issue (thank you very much Giles!!!):
SharePoint has a configuration cache and if it is not cleared you can have this kind of issue.
Follow the steps to solve the issue:
- Stop the OWSTIMER service on the problem SharePoint WFE server in the farm.
- On the problem server, navigate to:
Windows Server 2003 location: Drive:\Documents and Settings\All Users\Application Data\Microsoft\SharePoint\Config\GUID and delete all the XML files from the directory.
Windows Server 2008 location: Drive:\ProgramData\Microsoft\SharePoint\Config\GUID and delete all the XML files from the directory.
- Delete all the XML files in the directory. NOTE: ONLY THE XML FILES, NOT THE .INI FILE.
- Open the cache.ini with Notepad and reset the number to 1. Save and close the file.
- Start the OWSTIMER service on the server and wait for XML files to begin to reappear in the directory.
- IIS Reset (optional) – you can just recycle the app pool and it will work.
Thanks @twlamb for the revision…..