Monday, March 29, 2010

The file _app_bin/Web.sitemap required by XmlSiteMapProvider does not exist

I wanted to share something with those of You who use SharePoint MOSS 2007. I had one interesting problem with SharePoint after doing some customization of menus/navigation in SharePoint.


SharePoint navigation is done either by using Quick launch menus or by using Top Navigational menu. Both menus are standard out-of-the box menus in SharePoint. Since SharePoint is content management system, it handles those menus in some specific way. For example - after you add some lists to your site - SharePoint automatically add link to this list on the quick launch menu. This is cool feature, but what if you don't like this? Well, in this case - you need to substitute menu with xml. Basically, this substitution consists of several steps. First, you need to define CustomXmlContentMapProvider in web.config of the website you wish to edit. Second, you need to create the xml file with menu structure and place it somewhere within web site folder so it is accessible to the web application. Third, edit the default.master page in Sharepoint and define the DataSourceID and SiteMapDataSource. After you are done with this - you will have your own totally customizable menu structure of Sharepoint site.


Now, this is where tricky part starts. When I done this - everything worked fine - at least I thought so. From time to time, it looked totally random - people would receive "The file _app_bin/Web.sitemap required by XmlSiteMapProvider does not exist". Web.Sitemap is actually the xml file I made for menu structure. So, this error means that "XmlSiteMapProvider" couldn't find Web.sitemap. But thisisn't true because this file is located in _app_bin/Web.sitemap folder. Whenever I tried to open Sharepoint web site - everything opened succesfully. I would usually then double-check with the person that reported this error and usually then everything would be working. I was confused at that time. After some time, I noticed a pattern here - usually this happens early in the morning and usually after I open the website - error dissapears i.e. Sharepoint is then working for everyone (at least till next morning).

After I evaluated situation a little bit - I concluded that this could be related to permissions somehow and it happens after some period of inactivity of the website. Since, I am Sharepoint administrator, after I open the website - everything works so I concluded that after this Web.sitemap is loaded first time, everything is working because this Web.sitemap is somehow cached and is available for everyone until next period of long inactivity.

I then checked to see what permissions are effective on file Web.sitemap in Inetpub folder of Sharepoint website. I noticed that, only Administrators have access to web.sitemap. Since, I am Sharepoint administrator, I can access this website, but no domain users can access this file -> which could lead to this error if domain users try to access this file before any of the administrators. I then added read permissions to domain users group on file Web.sitemap and then - problem dissapeared! :=)

I have monitored Sharepoint for weeks after but still no error.

I hope this article will help you so you know that you need to give read permissions to domain users in domain or to Everyone group if this site is accessible from the internet.

Best regards,
Damir.




Below is the error I would get from time to time, randomly.
--

Server Error in '/' Application.


The file _app_bin/Web.sitemap required by XmlSiteMapProvider does not exist.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The file _app_bin/Web.sitemap required by XmlSiteMapProvider does not exist.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[InvalidOperationException: The file _app_bin/Web.sitemap required by XmlSiteMapProvider does not exist.]

System.Web.XmlSiteMapProvider.CheckSiteMapFileExists() +2603440

System.Web.XmlSiteMapProvider.GetConfigDocument() +226

System.Web.XmlSiteMapProvider.BuildSiteMap() +58

Microsoft.SharePoint.Navigation.SPXmlContentMapProvider.BuildSiteMap() +53

System.Web.XmlSiteMapProvider.get_RootNode() +15

System.Web.UI.WebControls.SiteMapDataSource.GetNodes() +229

System.Web.UI.WebControls.SiteMapDataSource.GetTreeView(String viewPath) +35

System.Web.UI.WebControls.SiteMapDataSource.GetHierarchicalView(String viewPath) +32

System.Web.UI.HierarchicalDataSourceControl.System.Web.UI.IHierarchicalDataSource.GetHierarchicalView(String viewPath) +10

System.Web.UI.WebControls.HierarchicalDataBoundControl.GetData(String viewPath) +25

System.Web.UI.WebControls.Menu.DataBindItem(MenuItem item) +56

System.Web.UI.WebControls.Menu.PerformDataBinding() +50

System.Web.UI.WebControls.HierarchicalDataBoundControl.PerformSelect() +85

System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73

System.Web.UI.WebControls.Menu.DataBind() +4

System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82

System.Web.UI.WebControls.Menu.EnsureDataBound() +40

System.Web.UI.WebControls.BaseDataBoundControl.OnPreRender(EventArgs e) +22

System.Web.UI.WebControls.Menu.OnPreRender(EventArgs e, Boolean registerScript) +15

System.Web.UI.WebControls.Menu.OnPreRender(EventArgs e) +25

Microsoft.SharePoint.WebControls.AspMenu.OnPreRender(EventArgs e) +142

System.Web.UI.Control.PreRenderRecursiveInternal() +80

System.Web.UI.Control.PreRenderRecursiveInternal() +171

System.Web.UI.Control.PreRenderRecursiveInternal() +171

System.Web.UI.Control.PreRenderRecursiveInternal() +171

System.Web.UI.Control.PreRenderRecursiveInternal() +171

System.Web.UI.Control.PreRenderRecursiveInternal() +171

System.Web.UI.Control.PreRenderRecursiveInternal() +171

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842

7 comments:

  1. Awesome fixed my problem, was banging my head trying to figure out.

    ReplyDelete
  2. i was not banging my head, i knew its a permission issue, but is what you did a best practice?is it secure?

    ReplyDelete
  3. wow. i think this is exactly what is happening to us. this post saved me so much time and frustration - I can't even begin to tell you how much i appreciate this.

    ReplyDelete
  4. Thanks, You shared awesome post. But for each deployment we have to do same config. that's the drawback.. So, I have done it another way.

    http://sasikumarreddyv.blogspot.in/2012/03/file-appbinwebsitemap-required-by.html

    ReplyDelete
  5. Thank you very much!
    I spent too much time for this problem..

    ReplyDelete
  6. Wer is d solution?

    ReplyDelete
  7. Great post, fixed our problem! Thanks

    ReplyDelete