The SharePoint 2010 "Search Service Application" stopped working.
I could not crawl the data, and I could not modify the topology. The data crawling procedure was suspended there forever.
So I decided to rebuild it. Obviously this service application is corrupted, that's why I could not remove it from Central Admin site. The PowerShell seems all right.
1. Use "Get-SPEnterpriseSearchServiceApplication" to get the GUID of the search service application.
2. Use "stsadm -o deleteconfigurationobject -id [GUID]" to delete it.
3. Use "Get-SPEnterpriseSearchServiceInstance" to get the GUID of the search service instances.
4. Use "Stop-SPEnterpriseSearchServiceInstance -id [GUID]" to stop the service instances.
Now we need to rebuild it. To avoid GUID in database name, we have to use PowerShell (again). It's not easy. Lucky that Jeremy Jameson shared an excellent post about how to build it through PowerShell script
All seems OK, except the error below when running "New-SPEnterpriseSearchServiceApplication"
New-SPEnterpriseSearchServiceApplication : A SharePoint database named SP_EnterpriseSearch already exists. You must supply another name for the new database.
At line:32 char:62
+ $searchApp = New-SPEnterpriseSearchServiceApplication <<<< -Name $serviceAppName `
+ CategoryInfo : InvalidData: (Microsoft.Offic...viceApplication: NewSearchServiceApplication) [New-SPEnterpriseSearchServiceApplication], SPDuplicateObjectException
+ FullyQualifiedErrorId : Microsoft.Office.Server.Search.Cmdlet.NewSearchServiceApplication
I double checked that the database "SP_EnterpriseSearch" was removed with "Search Service Application", so, what was wrong?
I had to assume this was caused by the "search service" corruption + SharePoint bug. There must be some orphaned objects left in the system.
So I removed the half-created "search service application", and then start to scan the database. With the help from Sorna Kumar Muthuraj, I searched the SharePoint Configuration database:
EXEC SP_SearchTables @Tablenames = '%', @SearchStr = '%SP_EnterpriseSearch%'
Then I deleted all relevant objects (and their child objects) from table "SP_Config.dbo.Objects". In my case, it's totally 4 objects.
That's it. The "Search Service Application" was created successfully after that.
Wednesday, August 28, 2013
Thursday, August 15, 2013
CU installation error - "There are no products affected by this package installed on this system"
The installation of SharePoint 2013 CU201308 was fine. But when I ran the SharePoint 2013 Products Configuration Wizard on the first web front end server, I got error message complaining that Hotfix KB2817616 was missing on one of the servers.
I thought I missed that server, but when I tried to install SharePoint 2013 CU201308 on that server, it said "There are no products affected by this package installed on this system".
I tried to Clearing the Configuration Cache, restarted the timer service, but nothing worked.
In terms of Cumulative Patch installation rule, there is no way to uninstall or re-install a CU patch. So I stuck there.
So this server have to be sacrificed to this CU installation. I disconnected this server from the farm, and then upgraded the farm successfully.
It won't hurt to give it a last chance. After join the server back to the farm, it's upgraded without any problem!
No sure what's the problem, but anyway, it works now.
[update, 20140106]
We can disconnect the server from the farm through PowerShell command "Disconnect-SPConfigurationDatabase –Confirm:$false", reference: http://technet.microsoft.com/en-us/library/ff607702(v=office.14).aspx
I thought I missed that server, but when I tried to install SharePoint 2013 CU201308 on that server, it said "There are no products affected by this package installed on this system".
I tried to Clearing the Configuration Cache, restarted the timer service, but nothing worked.
In terms of Cumulative Patch installation rule, there is no way to uninstall or re-install a CU patch. So I stuck there.
So this server have to be sacrificed to this CU installation. I disconnected this server from the farm, and then upgraded the farm successfully.
It won't hurt to give it a last chance. After join the server back to the farm, it's upgraded without any problem!
No sure what's the problem, but anyway, it works now.
[update, 20140106]
We can disconnect the server from the farm through PowerShell command "Disconnect-SPConfigurationDatabase –Confirm:$false", reference: http://technet.microsoft.com/en-us/library/ff607702(v=office.14).aspx
Monday, August 5, 2013
SharePoint - How to shrink "UsageAndHealthDB" database
Two months ago, our SharePoint farm got some "Usage Logging" issue (thanks for a windows update pack). After resolving the issue, a huge database "SP_UsageAndHealthDB" was left there.
In the database, we can see the space is consumed by "ULSTraceLog_Partition" tables.
So I went to Central Admin -> Monitoring -> Configure usage and health data collection, changed the "Maximum log file size" to 1GB. I thought it would affect both file system and logging database, but I was wrong. The logging database was not affected at all. Two months later, all historical log data is still there.
I just cannot find any solution online. So, I have to remove the data manually.
select MAX([LogTime]), MIN([LogTime]),COUNT(1)
FROM [SP_UsageAndHealthDB].[dbo].[ULSTraceLog_Partition3]
truncate table [SP_UsageAndHealthDB].[dbo].[ULSTraceLog_Partition3]
So far so good.
I totally agree that we should not modify any data directly from SQL Server. But, it seems that we don't have any other choice.
Please let me know if you can remove the log data from SharePoint platform, that will be strongly appreciated.
Thursday, August 1, 2013
Error Creating Control - Cannot find Web Project Item
I created a new SharePoint 2010 Visual Web Part project in Visual Studio 2012, and got the error message below when open a .ascx file in design mode:
Error Creating Control - LinkButtonSubmitCannot find web project item '~/sites/Sandpit/vwpUserProfileUpdate/vwpUserProfileUpdate.ascx'.
Warning message is:
Warning 1 E:\EricFang\VisualStudio\somepath\usercontrol.ascx: ASP.NET runtime error: Path cannot be null.
Parameter name: path E:\EricFang\VisualStudio\somepath\usercontrol.ascx 1 1 usercontrol
I even could not drag and drop any control from the tool box to the web form.
I built some similar projects before, and this was the first time that got this error. So I compared the .csproj file with other projects, but didn't notice any difference which cause the problem.
Then I spent a while searching on internet. Many developers got similar issues, such as here and here, but they don't suit my case.
In the end, quite lucky, I noticed that in the "Site URL" of the project, I used the server alias name instead of the computer name. Since it wouldn't hurt, I changed it, and BING! The problem disappeared!
(This value is actually stored in ".csproj.user" file)
Error Creating Control - LinkButtonSubmitCannot find web project item '~/sites/Sandpit/vwpUserProfileUpdate/vwpUserProfileUpdate.ascx'.
Warning message is:
Warning 1 E:\EricFang\VisualStudio\somepath\usercontrol.ascx: ASP.NET runtime error: Path cannot be null.
Parameter name: path E:\EricFang\VisualStudio\somepath\usercontrol.ascx 1 1 usercontrol
I even could not drag and drop any control from the tool box to the web form.
I built some similar projects before, and this was the first time that got this error. So I compared the .csproj file with other projects, but didn't notice any difference which cause the problem.
Then I spent a while searching on internet. Many developers got similar issues, such as here and here, but they don't suit my case.
In the end, quite lucky, I noticed that in the "Site URL" of the project, I used the server alias name instead of the computer name. Since it wouldn't hurt, I changed it, and BING! The problem disappeared!
(This value is actually stored in ".csproj.user" file)
Friday, June 28, 2013
SharePoint error: "Failed to find ACL for ScopeId: b19c18cd-34a7-4c2d-aca7-557039b3a156"
I got this error message from ULS log when trying to download an image file from a document library. Don't see any other problem and just cannot download the image file.
It turns out quite simple: SharePoint generated a lot of "Policy Usage Report" files (15k+) in "UsageReports" document library. After deleting these files, the problem disappeared.
Below are the error message I got from the web page.
Server Error in '/' Application.
--------------------------------------------------------------------------------
Cannot complete this action.
Please try again.0x80004005
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.Runtime.InteropServices.COMException: Cannot complete this action.
Please try again.0x80004005
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:
[COMException (0x80004005): Cannot complete this action.
Please try again.0x80004005 ]
Microsoft.SharePoint.Library.SPRequestInternalClass.GetAclForScope(String bstrWebUrl, Guid guidScopeId, Boolean fRequirePermissionCheck, Object& pvarAcl, UInt64& lAnonymousMask) +0
Microsoft.SharePoint.Library.SPRequest.GetAclForScope(String bstrWebUrl, Guid guidScopeId, Boolean fRequirePermissionCheck, Object& pvarAcl, UInt64& lAnonymousMask) +183
[SPException: Cannot complete this action.
Please try again.]
Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) +27861714
Microsoft.SharePoint.Library.SPRequest.GetAclForScope(String bstrWebUrl, Guid guidScopeId, Boolean fRequirePermissionCheck, Object& pvarAcl, UInt64& lAnonymousMask) +28084291
Microsoft.SharePoint.SPReusableAcl..ctor(SPRequest request, String webUrl, Guid scopeId, Boolean requirePermissionCheck) +74
Microsoft.SharePoint.SPSite.GetReusableAclForScope(Guid scopeId) +98
Microsoft.SharePoint.Publishing.<>c__DisplayClass3f.b__39() +203
Microsoft.SharePoint.<>c__DisplayClass4.b__2() +729
Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) +26712342
Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) +27759977
Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) +93
Microsoft.SharePoint.Publishing.BlobCache.HandleCachedFile(HttpContext context, BlobCacheEntry target, Boolean anonymousUser, SiteEntry currentSiteEntry) +2184
Microsoft.SharePoint.Publishing.BlobCache.RewriteUrl(Object sender, EventArgs e, Boolean preAuthenticate) +3917
Microsoft.SharePoint.Publishing.PublishingHttpModule.AuthorizeRequestHandler(Object sender, EventArgs ea) +56
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.5466; ASP.NET Version:2.0.50727.5456
[update 20130701]
Below are the error message I got from the web page.
Server Error in '/' Application.
--------------------------------------------------------------------------------
Cannot complete this action.
Please try again.
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.Runtime.InteropServices.COMException: Cannot complete this action.
Please try again.
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:
[COMException (0x80004005): Cannot complete this action.
Please try again.
Microsoft.SharePoint.Library.SPRequestInternalClass.GetAclForScope(String bstrWebUrl, Guid guidScopeId, Boolean fRequirePermissionCheck, Object& pvarAcl, UInt64& lAnonymousMask) +0
Microsoft.SharePoint.Library.SPRequest.GetAclForScope(String bstrWebUrl, Guid guidScopeId, Boolean fRequirePermissionCheck, Object& pvarAcl, UInt64& lAnonymousMask) +183
[SPException: Cannot complete this action.
Please try again.]
Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) +27861714
Microsoft.SharePoint.Library.SPRequest.GetAclForScope(String bstrWebUrl, Guid guidScopeId, Boolean fRequirePermissionCheck, Object& pvarAcl, UInt64& lAnonymousMask) +28084291
Microsoft.SharePoint.SPReusableAcl..ctor(SPRequest request, String webUrl, Guid scopeId, Boolean requirePermissionCheck) +74
Microsoft.SharePoint.SPSite.GetReusableAclForScope(Guid scopeId) +98
Microsoft.SharePoint.Publishing.<>c__DisplayClass3f.
Microsoft.SharePoint.<>c__DisplayClass4.
Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) +26712342
Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) +27759977
Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) +93
Microsoft.SharePoint.Publishing.BlobCache.HandleCachedFile(HttpContext context, BlobCacheEntry target, Boolean anonymousUser, SiteEntry currentSiteEntry) +2184
Microsoft.SharePoint.Publishing.BlobCache.RewriteUrl(Object sender, EventArgs e, Boolean preAuthenticate) +3917
Microsoft.SharePoint.Publishing.PublishingHttpModule.AuthorizeRequestHandler(Object sender, EventArgs ea) +56
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.5466; ASP.NET Version:2.0.50727.5456
[update 20130701]
Friday, June 7, 2013
SharePoint 2013 - PowerShell - How to update image url of web part pages
In SharePoint 2010, it's easy to update all "sub site logo url" and "web part page image url", below is the PowerShell script to update one Web Application.
$ImageUrl = "/_layouts/images/CompanyName/logo.png";
function UpdateSubsiteLogoUrl([string]$webApplicationURL)
{
Write-Host "webApplication URL: " $webApplicationURL
$webApp = Get-SPWebApplication $webApplicationURL
foreach($site in $webApp.Sites)
{
Write-Host "site URL: " $site.Url
foreach($CurrentWeb in $site.AllWebs)
{
[Boolean]$isContextNull = $false;
[System.Web.HttpContext]$htc = $null;
[System.IO.StringWriter]$sw = $null;
[System.Web.HttpResponse]$resp = $null;
[System.Web.HttpRequest]$req = $null;
Write-Host "CurrentWeb URL: " $CurrentWeb.Url
$CurrentWeb.SiteLogoUrl = $ImageUrl;
$CurrentWeb.Update();
# http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/607f3980-53c0-4007-bb34-9969ed6ea4fc
$web = $CurrentWeb
if ($null -eq [System.Web.HttpContext]::Current){
Write-Debug "Setting HttpContext";
$isContextNull = $true;
$sw = New-Object System.IO.StringWriter;
$resp = New-Object System.Web.HttpResponse $sw;
$req = New-Object System.Web.HttpRequest "", $web.Url, "";
$htc = New-Object System.Web.HttpContext $req, $resp;
$htc.Items["HttpHandlerSPWeb"] = $web -as [Microsoft.SharePoint.SPweb];
[System.Web.HttpContext]::Current = $htc;
if ($sw -ne $null){
$sw.Dispose()
}
} else {
Write-Debug "HttpContext already set" -ForegroundColor Red ;
}
foreach($list in $web.Lists)
{
if($list.Title -match "Pages" -and -not $list.Hidden)
{
#Write-Host "list.Title = " $list.Title
foreach ($currentPage in $list.RootFolder.Files)
{
if ($currentPage.Name -match ".aspx")
{
Write-Host "currentPage.ServerRelativeUrl = " $currentPage.ServerRelativeUrl
$CurrentWebPartManager = $currentPage.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared);
if ($CurrentWebPartManager -ne $null)
{
$CurrentWebPartManager.WebParts | ForEach-Object {
if ($_.Title -eq "Web Part Page Title Bar")
{
$_.Image = $ImageUrl;
$CurrentWebPartManager.SaveChanges($_);
}
}
}
}
}
}
}
if($isContextNull){
Write-Debug "Resetting HttpContext";
[System.Web.HttpContext]::Current = $null;
$isContextNull = $false;
}
$web.Dispose()
}
$site.Dispose();
}
}
This is not just for image files. All css, javascript files, etc. should be stored there if they are previously stored in farm system folder.
$ImageUrl = "/_layouts/images/CompanyName/logo.png";
function UpdateSubsiteLogoUrl([string]$webApplicationURL)
{
Write-Host "webApplication URL: " $webApplicationURL
$webApp = Get-SPWebApplication $webApplicationURL
foreach($site in $webApp.Sites)
{
Write-Host "site URL: " $site.Url
foreach($CurrentWeb in $site.AllWebs)
{
[Boolean]$isContextNull = $false;
[System.Web.HttpContext]$htc = $null;
[System.IO.StringWriter]$sw = $null;
[System.Web.HttpResponse]$resp = $null;
[System.Web.HttpRequest]$req = $null;
Write-Host "CurrentWeb URL: " $CurrentWeb.Url
$CurrentWeb.SiteLogoUrl = $ImageUrl;
$CurrentWeb.Update();
# http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/607f3980-53c0-4007-bb34-9969ed6ea4fc
$web = $CurrentWeb
if ($null -eq [System.Web.HttpContext]::Current){
Write-Debug "Setting HttpContext";
$isContextNull = $true;
$sw = New-Object System.IO.StringWriter;
$resp = New-Object System.Web.HttpResponse $sw;
$req = New-Object System.Web.HttpRequest "", $web.Url, "";
$htc = New-Object System.Web.HttpContext $req, $resp;
$htc.Items["HttpHandlerSPWeb"] = $web -as [Microsoft.SharePoint.SPweb];
[System.Web.HttpContext]::Current = $htc;
if ($sw -ne $null){
$sw.Dispose()
}
} else {
Write-Debug "HttpContext already set" -ForegroundColor Red ;
}
foreach($list in $web.Lists)
{
if($list.Title -match "Pages" -and -not $list.Hidden)
{
#Write-Host "list.Title = " $list.Title
foreach ($currentPage in $list.RootFolder.Files)
{
if ($currentPage.Name -match ".aspx")
{
Write-Host "currentPage.ServerRelativeUrl = " $currentPage.ServerRelativeUrl
$CurrentWebPartManager = $currentPage.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared);
if ($CurrentWebPartManager -ne $null)
{
$CurrentWebPartManager.WebParts | ForEach-Object {
if ($_.Title -eq "Web Part Page Title Bar")
{
$_.Image = $ImageUrl;
$CurrentWebPartManager.SaveChanges($_);
}
}
}
}
}
}
}
if($isContextNull){
Write-Debug "Resetting HttpContext";
[System.Web.HttpContext]::Current = $null;
$isContextNull = $false;
}
$web.Dispose()
}
$site.Dispose();
}
}
However, it doesn't work for SharePoint 2013.
The "fake" httpcontext trick stopped working in SharePoint 2013. All webparts appear as ErrorWebParts now, so we can't modify the the property of "Web Part Page Title Bar" web parts of web part pages.
We know that for SharePoint 2013 upgrade, the farm system folder "/_layouts/images" is changed to "/_layouts/15/images", so how can we do the changes for all web part pages?
The only solution I found is to abandon all references of "SharePoint farm system folder". It make sense. In the future, most of web sites will be hosted in cloud. There is no "system folder" of cloud (for developers and SharePoint administrators).
What I did is quite simple.
1. Create a document library for each web application, say "SharedAssets", in the root site of the root site collection;
2. Grant "read" rights of that document library to all users;
3. Change the image url in PowerShell script.
$ImageUrl = "/SharedImages/logo.png";
4. Update all web applications before upgrading the sites.
5. Done.
This is not just for image files. All css, javascript files, etc. should be stored there if they are previously stored in farm system folder.
Please let me know if you know how to change web part property through PowerShell script in SharePoint 2013, I really appreciate it.
Monday, June 3, 2013
SharePoint 2010 patch could not be installed. Error code 1603
Recently I rebuilt a WFE server. SharePoint 2010 SP1 was installed successfully. However, when trying to install CU 201304, I got the error message below:
MSI (s) (7C:CC) [13:46:54:523]: Product: Microsoft Search Server 2010 Core - Update 'Hotfix for Microsoft Project Server 2010 (KB2775426) 64-Bit Edition' could not be installed. Error code 1603. Additional information is available in the log file C:\Users\#SPSET~1\AppData\Local\Temp\2\coreserver-x-none_MSPLOG.LOG.
MSI (s) (7C:CC) [13:46:54:523]: Windows Installer installed an update. Product Name: Microsoft Search Server 2010 Core. Product Version: 14.0.6029.1000. Product Language: 0. Manufacturer: Microsoft Corporation. Update Name: Hotfix for Microsoft Project Server 2010 (KB2775426) 64-Bit Edition. Installation success or error status: 1603.
MSI (s) (7C:CC) [13:46:54:523]: Note: 1: 1729
MSI (s) (7C:CC) [13:46:54:523]: Note: 1: 2205 2: 3: Error
MSI (s) (7C:CC) [13:46:54:523]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1729
MSI (s) (7C:CC) [13:46:54:523]: Note: 1: 2205 2: 3: Error
MSI (s) (7C:CC) [13:46:54:523]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1709
MSI (s) (7C:CC) [13:46:54:523]: Product: Microsoft Search Server 2010 Core -- Configuration failed.
MSI (s) (7C:CC) [13:46:54:523]: Windows Installer reconfigured the product. Product Name: Microsoft Search Server 2010 Core. Product Version: 14.0.6029.1000. Product Language: 0. Manufacturer: Microsoft Corporation. Reconfiguration success or error status: 1603.
There was not much useful information in the error log. So I enabled windows installer logging, and got a lot of message like below.
Product: Microsoft Search Server 2010 Core. The application tried to modify a protected Windows registry key \Software\Classes\CLSID\{3050F667-98B5-11CF-BB82-00AA00BDCE0B}\InprocServer32.
Quite clear that the SharePoint patch installer doesn't have the rights to modify registry table. But, I had logged on with local administrator rights. So I tried to change the registry table manually, and got the error message below.
The permission settings of those registry entries are here:
One possible cause is Windows UAC. However, it's not this case. The UAC is disabled on local computer.
Not sure how this problem was raised. I had installed SharePoint server patches many times cross several farms. This was the first time got that issue.
I contacted network administrators, and confirmed there was no group policy restriction.
To fix the problem is easy. I downloaded a free tool DevxExec, then ran the command "devxexec.exe /user:TrustedInstaller E:\Setup\Microsoft\SharePoint\2010\ServicePack\CU201304\ubersrvprj2010-kb2775426-fullfile-x64-glb.exe".
As a quick fix, I am happy about the result. :-)
Subscribe to:
Posts (Atom)