Typically the 4965 error occurs doing Publishing Provisioning because of an access denied issue. I had blogged about that previously here: Event ID: 4965 - Publishing Provisioning Error.
Today while enabling the Publishing Infrastructure for a site collection, I got a 4965 but was due to a System.NullReferenceException. By looking at the error message (below), I’m going to assume that ‘site’ was null. After some digging, it turned out that the Alternate Access Mappings had an incorrect mapping. Not totally aware of the inner code here, but I’m assuming that its used at some point for AddSchedulingJobDefinitions.
Regardless, if you get a 4965 System.NullReferenceException, ensure that your AAM is good to go. 🙂
Event Type: Error
Event Source: Office SharePoint Server
Event Category: Publishing Provisioning
Event ID: 4965
Time: 1:53:09 PM
Event log message was: 'Failed to provision the scheduling job definitions. Page scheduling will not succeed.'. Exception was: 'System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.SharePoint.SPSecurity.CodeToRunElevatedWrapper(Object state)
at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)
at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode)
at Microsoft.SharePoint.Publishing.Internal.RootProvisioner.AddSchedulingJobDefinitions(SPSite site)'
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.