Consider the following scenario:
A SharePoint 2010 farm has a Web Front End Server with the “Microsoft SharePoint Foundation Web Application” service running and a separate Application Server with the “Microsoft SharePoint Foundation Workflow Timer Service” running (The server does not have the Web Application service running).
A workflow has been queued for resumption and the Application server with the Workflow Timer Service tries to resume the workflow but fails.
In this scenario the application server fails to resume the Workflow timer service and the workflow gets stuck in "In progress" status. The Workflow History list shows "workflow failed to run." message
SharePoint ULS log entries may include the following:
OWSTIMER.EXE (0x0E5C) 0x2184 SharePoint Foundation Workflow Infrastructure 72fu Unexpected Load Workflow Class: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.Workflow.SPWinOeHostServices.EnsurePluggableServices(SPSite site, SPWorkflowExternalDataExchangeServiceCollection services, ExternalDataExchangeService existingServices) at Microsoft.SharePoint.Workflow.SPWinOeHostServices..ctor(SPSite site, SPWeb web, SPWorkflowManager manager, SPWorkflowEngine engine)
OWSTIMER.EXE (0x0E5C) 0x2184 SharePoint Foundation Workflow Infrastructure 98d8 Unexpected System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.Workflow.SPWinOeHostServices.EnsurePluggableServices(SPSite site, SPWorkflowExternalDataExchangeServiceCollection services, ExternalDataExchangeService existingServices) at Microsoft.SharePoint.Workflow.SPWinOeHostServices..ctor(SPSite site, SPWeb web, SPWorkflowManager manager, SPWorkflowEngine engine)
OWSTIMER.EXE (0x0D64) 0x0E98 SharePoint Foundation Workflow Infrastructure frg9 Medium Workflow could not be run because SPWebApplication.UpdateWorkflowConfigurationSettings was not previously called, and the Web Application service has been disabled on this server. Call UpdateWorkflowConfigurationSettings or turn on the Web Application service for this server.
Cause:
The Workflow Timer Service tries to read the workflow batchsize settings from the web.config or configuration database for a web application. By default, the batchsize setting is in web.config file if the server is running the Web Application service.
If the Web Application service is not running on the same server and script in Method 1 (under the 'Resolution' section) has not been run, the batchsize setting is neither in the web.config file nor in the configuration database, then the operation fails.
Solution:
Method 1:
Locate one Web Front End server which has Web Application service running, run the following PowerShell command to copy workflow-related configuration from the web.config to the configuration database so it will be available from every server in the Farm.
• $webapp = Get-SPWebApplication -identity http://<web app name>
• $webapp.UpdateWorkflowConfigurationSetttings()
Method 2:
Start the Web Application Service on all servers that have the Workflow Timer Service running.
Method 3:
Disable the Workflow Timer Service on servers that are not running the Web Application service