Friday, May 29, 2009

SharePoint SP2 Alternate Access Mapping issue...continued

In this post I want to mention that finally, it seems that the issue with the AAMs appears after installing April Cumulative Updates. The WSS 3.0 SP2 and MOSS SP2 are "innocents". This has been said, and now that you are aware of this problem, it's up to you to decide wether to install April CU or not.

The following links may help make your decision :
Hope this information helps.

Tuesday, May 26, 2009

SharePoint SP2 Alternate Access Mapping issue

<Update date="August, 27, 2009">
The fix for this issue has been published in August 2009 CU : The Kb states the following
, amongst the issues fixed :
'You have a Web application that has more than five incoming URLs. You cannot change Alternate Access Mappings (AAM) settings after you install the 2007 Microsoft Office system cumulative update that was released in April 2008.'

Thank you Joe Reichard.

I wonder if any of you has encountered this problem. Just after installing WSS and MOSS SP2 and April Cumulative Updates, SharePoint began to throw the following exception, when there are multiple Alternate Access Mappings (in my case more than six) and try to add or delete one :

Unexpected end of file has occurred. The following elements are not closed: MappedUrl, AlternateDomain, AlternateDomains. Line 25, position 34.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res, String arg)
at System.Xml.XmlTextReaderImpl.ThrowUnclosedElements()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.LoadXml(String xml)
at Microsoft.SharePoint.Administration.SPAlternateUrlCollection.HasMissingUrl(String xml)
at Microsoft.SharePoint.Administration.SPContentDatabase.UpdateAlternateAccessMapping(SPAlternateUrlCollection collection)
at Microsoft.SharePoint.Administration.SPAlternateUrlCollection.UpdateAlternateAccessMappingInContent()
at Microsoft.SharePoint.Administration.SPAlternateUrlCollection.Update()
at Microsoft.SharePoint.Administration.SPAlternateUrlCollection.Delete(Int32 index, Boolean update)
at Microsoft.SharePoint.Administration.SPAlternateUrlCollection.Delete(String incomingUrl, Boolean update, Boolean throwIfNotFound)
at Microsoft.SharePoint.ApplicationPages.EditIncomingUrlPage.BtnDelete_Click(Object sender, EventArgs e)
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

After this exception is thrown, it's impossible to add or delete an Alternate Access Mapping, extend or unextend the web application. The same error shows.

This issue began to happen just after installing WSS and MOSS SP2 and the cumulative updates of april 2009. I have not seen it with SP1.

After many digging ups, I found out that SharePoint stores the AAMs in two places :

1. In the config DB, exactly in the dbo.Objects table
2. In the content DB, in the table dbo.DatabaseInformation in a line where the name is 'AlternateAccessMappingXml' and the value (nvarchar(1023)) is an Xml string containing all the AAMs. This line is absent in SP1.

So, the “Unexpected end of file has occurred” that SharePoint is talking about is the xml string stored in the line ‘AlternateAccessMappingXml’. Remember this string is limited to 1023 characters. Therefore, when the number of AAMs is big, it just does not fit in the field. The xml string is then truncated to 1023 characters and becomes invalid xml.

It is very easy to reproduce the issue :

1. Create a new web application with a Publishing site for example “BlueBand”.
2. Extend the Internet zone (or any zone) of the web application
3. Add six or more Alternate Access Mapping to the zone extended
4. Perform a IISRESET
5. Try to delete the last AAM or add a new one.

At the moment the only workaround I found is to alter the xml string in the content database and, make it fit in 1023 characters and well formed. Of course in coherence with what is stored in the config DB. But, I do not recommand this solution to any one since it is not supported. Use it at your own risk.

My colleague Mario Leblond has also blogged in french on this issue. You can read him here