Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

This issue is related to this post.

I get an error message when the publishing feature is activated on sites of certain types. This means that I also get an error message when I create certain sites that are dependent on the Publishing Feature (and thereby activate the feature on site creation) e.g. Enterprise Wiki.

In my ULS-log, I see that the publishing feature is being activated. When it's almost done (after the event LRO - Starting background thread, job=Updating available web templates, this=50934842), it goes for another publishing provisioning taks, but it returns the following exception:

InitializePublishingWebDefaults failed. Microsoft.SharePoint.SPException: The object specified does not belong to a list.    
at Microsoft.SharePoint.SPWeb.GetItem(String strUrl, Boolean bFile, Boolean cacheRowsetAndId, Boolean bDatesInUtc, String[] fields)    
 at Microsoft.SharePoint.SPFile.get_Item()    
 at Microsoft.SharePoint.Publishing.MasterUrlProperty.SetDirectValue(String value, SPWeb web)    
 at Microsoft.SharePoint.Publishing.InheritableProperty`1.SetInherit(Boolean inherit, Boolean forceAllSubWebInherit, String successUrl, String failureUrl, Boolean& updateRequired)    
 at Microsoft.SharePoint.Publishing.InheritableProperty`1.SetInherit(Boolean inherit, Boolean forceAllSubWebInherit, Boolean& updateRequired)    
 at Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.SetMasterPageProperties(PublishingWeb area, Boolean& updateRequired)    
 at Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.SetLayoutRelatedProperties(PublishingWeb area, Boolean& updateRequired)    
 at Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.InitializePublishingWebDefaults()

and after that the following error message is shown / logged:

Event log message was: 'Failed to initialize some site properties for Web
 at Url: 'http://local/entwiki''. Exception was: 'Microsoft.SharePoint.SPException: The object specified does not belong to a list.    
 at Microsoft.SharePoint.SPWeb.GetItem(String strUrl, Boolean bFile, Boolean cacheRowsetAndId, Boolean bDatesInUtc, String[] fields)    
 at Microsoft.SharePoint.SPFile.get_Item()    
 at Microsoft.SharePoint.Publishing.MasterUrlProperty.SetDirectValue(String value, SPWeb web)    
 at Microsoft.SharePoint.Publishing.InheritableProperty`1.SetInherit(Boolean inherit, Boolean forceAllSubWebInherit, String successUrl, String failureUrl, Boolean& updateRequired)    
 at Microsoft.SharePoint.Publishing.InheritableProperty`1.SetInherit(Boolean inherit, Boolean forceAllSubWebInherit, Boolean& updateRequired)    
 at Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.SetMasterPageProperties(PublishingWeb area, Boolean& updateRequired)    
 at Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.SetLayoutRelatedProperties(PublishingWeb area, Boolean& updateRequired)    
 at Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.InitializePublishingWebDefaults()'

The strange thing is that this only happens when I use my custom master. I have a feature which loops through all the webs in a sc and applies this method:

public static void ApplyBrandingMaster(SPWeb web)
        {
            Uri masterUri = new Uri(web.Site.RootWeb.Url + "/_catalogs/masterpage/custom_main.master");
            web.MasterUrl = masterUri.AbsolutePath;
            web.CustomMasterUrl = masterUri.AbsolutePath;
            web.Update();
        }

It seems that if the master is NOT applied, there is no error. What could be wrong? I don't see how the master and the publishing feature are related this way.

share|improve this question
    
How do you provision your custom_main.master file? programmatically/with Elements.xml/upload to masterpage gallery manually? –  Andrey Markeev May 2 '11 at 11:26
    
Using Elements.xml<Module Name="MasterPages"> <File Path="MasterPages\custom_main.master" Url="_catalogs/masterpage/custom_main.master" /> </Module> –  tarjeieo May 2 '11 at 11:43
    
the Url is wrong –  trgraglia May 16 '11 at 9:55

3 Answers 3

up vote 4 down vote accepted

Please, try to add List="116" attribute to your Module element, as it is shown in this MSDN how-to:

http://msdn.microsoft.com/en-us/library/ms441170.aspx

<Module Name="MasterPages" List="116" Url="_catalogs/masterpage"> 
  <File Path="MasterPages\custom_main.master" Url="custom_main.master" /> 
</Module>
share|improve this answer
    
Thanks! It works. I also added "Type="GhostableInLibrary" at the same time, but that shouldn't matter. –  tarjeieo May 2 '11 at 12:56
    
Weird - It doesn't work on the server, just local on my machine. One weird thing is that the master doesn't show in the master page gallery on the server, only on my machine. :S –  tarjeieo May 3 '11 at 8:50
    
So, do you keep getting the same error on server, or you got another error? Maybe it's just something like a cache? Have you done iisreset or reboot? –  Andrey Markeev May 3 '11 at 9:22
    
Reboot and iisreset didn't fix it. I fixed the problem by opening the masterpage folder in SP Designer and deleting the master page from there. When I activated the feature again, it correctly deployed the file to the master page gallery (with List=116 applied to it). Thanks for the help –  tarjeieo May 3 '11 at 9:44

I ran into this same problem and it turned out that the person creating the subsite didn't have the proper permission to get access to the Master Page Gallery in the root of the site collection, where my master page lived, because we had created an alternate Restricted Readers group. You can read a more thorough explanation of the problem (and my particular solution) here: http://blog.beckybertram.com/Lists/Posts/Post.aspx?ID=181.

share|improve this answer

programatically activate Publishing features in site level and web level. this will help you to solve this issue.

Following two methods can use to activate Site collection and web features.

        public static void ActivateSiteCollectionFeatures(SPWeb web, string featureId)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(web.Url))
                {
                    using (SPWeb newWeb = site.OpenWeb())
                    {
                        newWeb.AllowUnsafeUpdates = true;
                        SPFeatureCollection featureCollection = newWeb.Site.Features;
                        featureCollection.Add(new Guid(featureId), true);
                        newWeb.Update();
                        newWeb.AllowUnsafeUpdates = false;

                    }
                }
            });
        }

        public static void ActivateWebFeatures(SPWeb web, string featureId)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(web.Url))
                {
                    using (SPWeb newWeb = site.OpenWeb())
                    {
                        newWeb.AllowUnsafeUpdates = true;
                        SPFeatureCollection featureCollection = newWeb.Features;
                        featureCollection.Add(new Guid(featureId), true);
                        newWeb.Update();
                        newWeb.AllowUnsafeUpdates = false;

                    }
                }
            });
        }
share|improve this answer
    
Some more information, ie on how to programmatically active publishing will help in this case. –  Hugh Wood Nov 22 '12 at 16:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.