SharePoint Content Deployment - Identifying Object Causing Error

Monday, 7 April 2008 22:13 by RanjanBanerji

Yet another problem with SharePoint 2007 content deployment is that its errors are not very informative.  The fact that content deployment is a delicate feature that tends to break with the slightest hiccup one would think that Microsoft should at least log out a sensible message.

Here is an error I got a few days ago:

The given key was not present in the dictionary. at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Microsoft.SharePoint.Deployment.ListItemSerializer.GetFileUrl(SerializationInfoHelper infoHelper, SPWeb web) at Microsoft.SharePoint.Deployment.ListItemSerializer.CreateListItem(SerializationInfoHelper infoHelper, Int32 listItemId, SPWeb web, SPList list, Boolean isIdTaken, String& listItemServerRelativeUrl) at Microsoft.SharePoint.Deployment.ListItemSerializer.SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector) at Microsoft.SharePoint.Deployment.XmlFormatter.ParseObject(Type objectType, Boolean isChildObject) at Microsoft.SharePoint.Deployment.XmlFormatter.DeserializeObject(Type objectType, Boolean isChildObject, DeploymentObject envelope) at Microsoft.SharePoint.Deployment.XmlFormatter.Deserialize(Stream serializationStream) at Microsoft.SharePoint.Deployment.ObjectSerializer.Deserialize(Stream serializationStream) at Microsoft.SharePoint.Deployment.ImportObjectManager.ProcessObject(XmlReader xmlReader) at Microsoft.SharePoint.Deployment.SPImport.DeserializeObjects() at Microsoft.SharePoint.Deployment.SPImport.Run()

 

Great! and just what am I supposed to do about this?  After speaking to our Microsoft tech support folks I found out that this error can occur if a page has been deleted then recovered from the recycle bin.  Apparently Content Deployment does not like that.  Fair enough, but wait, the job I was running deployed 830 items.  The application is used by thousands of users.  So how am I to find out which of the 830 items was the culprit, as in was deleted and then recovered.  The error message does not tell you the name or ID of the object in question.  Thanks so much Microsoft and don't tell users that this information is hard to get at.  If you are dealing with an object you better know its name, ID or some usable identified before reporting the error.  Else why even report the error?

Now Microsoft and its MVPs have spent a lot of time calling SharePoint a development platform rather than a poorly stitched up hack. Let me prove to you why they are all correct.  You see, if you write a little code using the SharePoint object model you will be able to get some additional information that Microsoft decided not to share.  It's not a bug, its a feature.  This is why one can claim its a development platform.

OK, enough cynicism.  I have many other gems to share on that front in upcoming blog posts.  For now let's try to find a way to get some help.

You can create a console application (or wait forever for me to complete my SharePoint Helper application) to make once change on how Content Deployment works.

In the application get the Content Deployment Path object and set KeepTemporary to true.

Microsoft.SharePoint.Publishing.Administration.ContentDeploymentPath.GetInstance( pathName ).KeepTemporaryFiles

Now run Content Deployment.  When complete as in when you get an error do the following:

  • Look at the Content Deployment Job's details.  It will say some thing like 800 objects exported, 250 imported and that it failed.  Keep teh 250 number in mind.
  • Collect the error message and hope someone has an explanation as to what that error implies.
  • On the source farm's Central Admin computer go to the TEMP folder where SharePoint will now leave the files used to export content.  You can find this by reading http://techblog.ranjanbanerji.com/post/2008/02/13/SharePoint-2007-Content-Deployment-Error-Out-of-disk-space.aspx
  • In the temp folder you will see a folder named ContentDeployment with sub folders named with GUIDs.  One of the GUID named folders is your job that failed.  Check the timestamp of the files in the folders, not the folder itself and find  which is the one you need.
  • In the folder you will find several CAB files.  Find the latest one and open it.  In it you will find several files including the manifest.xml file.
  • Open the manifest.xml file and find the 251st SPObject element (because your job reports said failure after importing 250 objects)
  • If you are lucky this is the object that failed.  Get it's details and start researching what went wrong.

 

If you get an error while exporting you can sift through the ULS logs or create a console application with a few lines of code as such:

using Microsoft.SharePoint.Publishing.Administration;

namespace TestRun {
    class Program {
        static void Main( string[] args ) {
            string jobName = args[ 0 ];
            ContentDeploymentJob job = Microsoft.SharePoint.Publishing.Administration.ContentDeploymentJob.GetInstance( jobName );
            job.Run();
            job.Dispose();
        }
    }
}

jobName is the name of a job that you have already created using the Central Administration.  When you run your console application you will see that SharePoint Content Deployment code will automatically spit out every object being exported to the console.  If it fails on any object, well the object name and error will be right there in front of you.  What is also interesting is that when you run a job from the console you can go to the Central Administration Content Deployment Page and see that the job is running and monitor its progress from there too.

So, now you have two code based approaches to help you debug your Content deployment problems.  Simple isn't it? ;-)

 

Tags:  
Categories:   SharePoint
Actions:   E-mail | Permalink | Comments (4) | Comment RSSRSS comment feed

Comments

April 16. 2008 15:47

Stefan Goßner

Just a short note on the last paragraph: often the object causing the problem on export is the next after the ony that was listed.
The reason is that before writing the information about which object is about to be exported the job already inspected the object and checked the consistency.
With other words: The object name "right there in front of you" might be the last successful exported item - not the one causing the problem.

Cheers,
Stefan

Stefan Goßner

October 23. 2008 21:07

Travis Lingenfelder

When I experianced this problem, it was due to a lookup column on a list referencing a lookup list that no longer existed.

Travis Lingenfelder

November 8. 2008 22:50

Tyler Butler

You don't need to create a console app or write code at all to change the KeepTemporaryFiles setting.  You can use the editcontentdeploymentpath stsadm.exe command to change this setting at commandline. See more info at technet.microsoft.com/en-us/library/cc262814.aspx. Also, you can run the job from commandline using the runcontentdeploymentjob stsadm command.

Tyler Butler

November 10. 2008 08:43

RanjanBanerji

Tyler,

Thanks for the information.  I wish I had that when I was working with MOSS.  I ended up learning that a lot can be done via stsadm that cannot be done via the Central Admin UI.  This issue adds to that.  Not sure why MS decided to create such an underfeatured UI for CA and Content Deployment.  But anyway....

Thanks,

Ranjan

RanjanBanerji

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading