Tuesday, December 30, 2008

You Got Mail (Or Not) Email Router Service fails to start

posted at: 9:19 AM by Aaron Elder wrote this

Recently, we recently had a power failure at one of our data centers which for a few reasons resulted in a hard shutdown of our CRM Server.  After the power came back on, the server started normally and everything seemed to be working well.  Normally that is, with the exception of the Microsoft CRM Email Router service, which failed to start.  The failure error was rather useful and the fix was rather easy.  Here is the error:

router issue

The E-mail Router service could not run the service main background thread. The E-mail Router service cannot continue and will now shut down.

System.Configuration.ConfigurationErrorsException: The E-mail router service cannot access system state file Microsoft.Crm.Tools.EmailAgent.SystemState.xml. The file may be missing or may not be accessible.

The E-mail Router service cannot continue and will now shut down. --->

System.Xml.XmlException: Root element is missing.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at System.Xml.XmlDocument.Load(String filename)
   at Microsoft.Crm.Tools.Email.Providers.ConfigFileReader..ctor(String filePath, ServiceLogger serviceLogger)
   at Microsoft.Crm.Tools.Email.Providers.SystemState.Initialize(ServiceLogger serviceLogger)
   at Microsoft.Crm.Tools.Email.Agent.ServiceCore.InitializeSystemConfiguration()
   --- End of inner exception stack trace ---
   at Microsoft.Crm.Tools.Email.Agent.ServiceCore.
InitializeSystemConfiguration()
   at Microsoft.Crm.Tools.Email.Agent.ServiceCore.ExecuteService()

The key here is:

“The file may be missing or may not be accessible.”

The first questions to ask are “what file is missing or not accessible” and “where are you looking for it”.  The error tells us that the file in question is Microsoft.Crm.Tools.EmailAgent.SystemState.xml which I happen to know was located in the Email router folder, c:\Program Files\Microsoft CRM Email\Service.  (Of course if I didn’t know this, I could have searched for it or used a tool like FileMon to see where the service was trying to find it) 

Upon examining the state XML file, something was indeed not right:

Something is amiss

The solution in this case was to simply delete the file (or rename it) so that the service would create a new state file and continue working normally.

Fixing the file

Cheers,

This posting is provided "AS IS" with no warranties, and confers no rights.

posted at: 9:19 AM by Aaron Elder

No comments: