Have you ever encountered the error? I have .. and solved it.
This error is basically related to the module element and usually exists when you try to provision a file to the SharePoint site which never exists in the physical path / file system of the server.
Here is a sample case:
I am trying to provision a page named stylish.aspx to pages library same as default.aspx in onet.xml
<Module Name="SampleModule" Url="$Resources:cmscore,List_Pages_UrlName;" Path="">
<File Url="Default.aspx" NavBarHome="false" Type="GhostableInLibrary">
<Property Name="Title" Value="My Default Page" />
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx,
~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx;" />
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_page_name;" />
</File>
<File Url="Stylish.aspx" NavBarHome="false" Type="GhostableInLibrary">
<Property Name="Title" Value="My Stylish Page" />
<Property Name="PublishingPageLayout"
Value="~SiteCollection/_catalogs/masterpage/ MyPageLayout.aspx, ~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx" />
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_page_name;" />
</File>
</Module>
If you try the preceding case then you will get the error, unable to instantiate module.
Well what's the problem?
Yes, I was trying to add page named Stylish.aspx with virtual url Stylish.aspx that did not exist.
If you open any site template directory under [14]\Layouts\Template\SiteTemplate then you will find default.aspx and that's the reason why SharePoint needs that SharePoint searches file named default.aspx on file system and then provisions file to SharePoint site.
Solution:
So the error can be solved by using a Name attribute of the File Element.
<Module Name="SampleModule" Url="$Resources:cmscore,List_Pages_UrlName;" Path="">
<File Url="Default.aspx" NavBarHome="false" Type="GhostableInLibrary">
<Property Name="Title" Value="My Default Page" />
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx, ~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx;" />
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_page_name;" />
</File>
<File Name="Stylish.aspx" Url="Default.aspx" NavBarHome="false" Type="GhostableInLibrary">
<Property Name="Title" Value="My Stylish Page" />
<Property Name="PublishingPageLayout"
Value="~SiteCollection/_catalogs/masterpage/ MyPageLayout.aspx, ~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx" />
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_page_name;" />
</File>
</Module>