23 September 2009

"Failed on Start (retrying)," said the workflow

Seemingly inexplicably, SharePoint will less than always cooperate. In this case, it happened after a major round of refactoring custom workflow solutions, but ULS logs and other debugging techniques were proving fruitless. After going through the various debugging tips posted on various blogs such as:


http://blogs.msdn.com/wael/archive/2008/01/11/workflow-failed-on-start-retrying.aspx


I found the solution was don't refactor so deeply, or really know when an XML attribute is referring to a library.classname or namespace.classname (OUCH, the subtlety).

e.g. in my case, workflow.xml's attribute for

CodeBesideClass = "unbudgetedBI_InitialApprovalWF.Workflow1"

then the workflow project (called "unbudgetedBI_InitialApprovalWF") has a workflow file called "initialapproval.cs" (with corresponding .rules and .desiginer.cs). Within this c# file is the namespace "unbudgetedBI_InitialApprovalWF" and a public class "Workflow1".

When trying to launch the workflow (after watching the submit_click method of the initation / instantiation form fire successfully within a debug session), the Site.WorkflowManager.StartWorkflow() does not cause an exception within the debugger, but the workflow status becomes "Failed on Start (retrying)".

ULS logs are chock full of valuable information, but most of it is irrelevant to the problem at hand, so I recommend changing the logging settings such that All events are ignored;

Central Administration > Operations > Diagnostic Logging Event Throttling. Category= All, Least critical event to report to the trace log= None. Press OK.

then, do it again but give yourself verbose logging for 'general';
Central Administration > Operations > Diagnostic Logging Event Throttling. Category= General, Least critical event to report to the trace log= Verbose. Press OK.

Now when the workflow failure occurs, you see this:
Unknown SPRequest error occurred. More information: 0x8000ffff
Unable to locate the xml-definition for CType with SPContentTypeId '0x01080100FD8D480B48CA4A928E9D31E74A4134B1', exception: Microsoft.SharePoint.SPException: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)) ---> System.Runtime.InteropServices.COMException (0x8000FFFF): Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
at Microsoft.SharePoint.Library.SPRequestInternalClass.GetGlobalContentTypeXml(String bstrUrl, Int32 type, UInt32 lcid, Object varIdBytes)
at Microsoft.SharePoint.Library.SPRequest.GetGlobalContentTypeXml(String bstrUrl, Int32 type, UInt32 lcid, Object varIdBytes) --- End of inner exception stack trace ---
at Microsoft.SharePoint.Library.SPRequest.GetGlobalContentTypeXml(String bstrUrl, Int32 type, UInt32 lcid, Object varIdBytes)
at Microsoft.SharePoint.SPContentTypeCollection.FillCollection(SPRequest req, SqlDataReader rdr, Boolean openWeb)

What is this contenttype that is missing, we are left to wonder. What a wild goose chase that creates! So I'll spare you more heartache and headache and tell you simply: don't refactor too much. In this case, I changed the name of the workflow file within the project. Apparently the XML attribute CodeBesideClass refers not to a namespace.classname but to libraryname.classname AND a class name within the c# file should reflect the name of the file itself (but I am no c# guru).

So I changed the filename from "initialapproval.cs" back to the default "Workflow1.cs" and my workflow ran just fine.

At least this made me laugh:


Homer: [reading screen] "To Start Press Any Key".

Where's the ANY key?

I see Esk ["ESC"], Catarl["CTRL"], and Pig-Up ["PGUP"].

There doesn't seem to be any ANY key!

Woo! All this computer hacking is making me thirsty. I think I'll order a TAB.
[presses TAB key]



Homer: Trying is the first step towards failure.

No comments:

Post a Comment

firstly, thanks in advance for your comment - I don't get very many, so I'm sure to follow up if you leave me a way - secondly, come again.