Lately, I have been working a lot with site templates in MOSS 2007. I have seen common issues which keep occurring now and then. I am posting the resolution of those since you might also run across them frequently.
File Cannot be found
- This one is easy. In 99% of the cases, this usually occurs due to missing master page. If the site template has been created out of a site having a custom master page and if that master page is not present in the target machine, be ready to face this error. It can be simply resolved by uploading the required master page in Master page gallery of the target site collection.
- Note that, if the site template contains custom webparts or user controls, this error would also come if the assembly for those controls is not found. Resolution would be to simply put the correct assemblies in bin directory of the target application and update the web.config with <safecontrol> entries.
- You would also face the same error if the site template is a Publishing site and one of the pages in its Pages Library have been built out of a custom Page Layout. The reason is simple, page layouts are not packaged in the site template. There is no resolution to this error. You might get away by uploading the required page layout in the page layouts gallery of the target site collection , but I recommend against it. That’s one of the reasons, Microsoft does not officially support saving Publishing Sites as Template (The link in Site Settings disappears when you activate Publishing feature :)).
The template you have chosen is invalid or cannot be found
- If you are trying to apply the custom site template (programmatically) and if the template is not present.
Add the new template by using stsadm –o addtemplate –filename <filename.stp> –title <title>
- You can also get this error when applying the template through GUI. Obviously, the template is present but sharepoint is somehow finding it to be invalid. One of the reasons for this could be version mismatch. You cannot restore the template created out of SP1 to a non-SP1 installation of MOSS.
Resolution: Upgrade the source server and re-create the template.
(I am not sure if the template created from non-SP version can be applied to SP1 installation of MOSS).
- Thirdly, this error also comes when you have feature dependency missing. Basically the site from which the template was created has one or more custom feature activated on it which are not present on the target installation.
If you know the missing feature, install the feature on the target machine.
However, even if you have made sure that you have all the required features present and are still facing this error, it can be easily debugged.
Rename the .stp file to .cab file and extract manifest.xml out of it. If we open the manifest.xml, it would contain the list of dependent feature ids in a section like this:
The feature IDs listed under SiteFeatures tag are the site collection features on which the site was dependent upon when the site template was saved as a template.
Similarly, As you might have guessed, features IDs listed under WebFeatures tag are Site features on which the template was dependent.
Armed with this information, you can simply do a text search on Features folder of your target installation to see which feature is missing and deploy-activate the missing feature on the target machine. Usually, I have seen custom feature are at the bottom of the list and out of the box features are at the top, but don’t take this observation to be granted in your case :).
If you know of any other resolutions, or fighting/fought with any similar issue , do leave me a comment and I’ll update my post (along with credits ofcourse).