SharePoint Solution Package Deploy Random Crashes
I keep seeing this error sporadically during solution deployment and / or feature activation ...
Copying this file failed. This operation uses the SharePoint Administration Service (spam) and cannot be contacted. If the service is stopped or disabled, start it and try again.
Below is the PowerShell script used for deployment:
$programfiles_path = $null
$stsadm_path = $null
$url = $null
$solution = $null
$feature = $null
$appPoolName = $null
$url = "http://" + ${env:COMPUTERNAME}
$programfiles_path = ${env:ProgramW6432}
if ($programfiles_path -eq $null)
{
$programfiles_path = ${env:ProgramFiles}
}
$stsadm_path = $programfiles_path + "\common files\microsoft shared\web server extensions\12\bin\stsadm.exe"
if(!(test-path $stsadm_path))
{
echo "stsadm.exe was not found: $stsadm_path"
exit -1
}
ECHO "***********************************"
ECHO "*** Contoso.Common.SolutionPackage ***"
ECHO "***********************************"
$solution = "Contoso.Common.SolutionPackage.wsp"
ECHO "*** add the solution ***"
& $stsadm_path -o addsolution -filename $solution
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
ECHO "*** deploy the solution ***"
& $stsadm_path -o deploysolution -name $solution -immediate -allowgacdeployment -url $url -force
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
$feature = "Contoso.Common.Infrastructure"
ECHO "*** activate feature(s) ***"
& $stsadm_path -o activatefeature -name $feature -url $url -force
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
$feature = "Contoso.CustomCAS"
ECHO "*** activate feature(s) ***"
& $stsadm_path -o activatefeature -name $feature -url $url -force
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
$feature = "Contoso.Common.WebParts"
ECHO "*** activate feature(s) ***"
& $stsadm_path -o activatefeature -name $feature -url $url -force
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
$feature = "Contoso.ExcelExtender"
ECHO "*** activate feature(s) ***"
& $stsadm_path -o activatefeature -name $feature -url $url -force
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
ECHO "*********************************"
ECHO "*** Contoso.Something ***"
ECHO "*********************************"
$solution = "Contoso.Something.wsp"
ECHO "*** add the solution ***"
& $stsadm_path -o addsolution -filename $solution
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
ECHO "*** deploy the solution ***"
& $stsadm_path -o deploysolution -name $solution -immediate -allowgacdeployment -url $url -force
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
$feature = "Contoso.Something"
ECHO "*** activate feature(s) ***"
& $stsadm_path -o activatefeature -name $feature -url $url -force
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
ECHO "*********************************"
ECHO "*** Contoso.Nothing ***"
ECHO "*********************************"
$solution = "Contoso.Nothing.wsp"
ECHO "*** add the solution ***"
& $stsadm_path -o addsolution -filename $solution
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
ECHO "*** deploy the solution ***"
& $stsadm_path -o deploysolution -name $solution -immediate -allowgacdeployment -force
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
$feature = $null
ECHO "*****************************************"
ECHO "*** Contoso.Everything ***"
ECHO "*****************************************"
$solution = "Contoso.Everything.wsp"
ECHO "*** add the solution ***"
& $stsadm_path -o addsolution -filename $solution
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
ECHO "*** deploy the solution ***"
& $stsadm_path -o deploysolution -name $solution -immediate -allowgacdeployment -url $url -force
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
$feature = "Contoso.Everything"
ECHO "*** activate feature(s) ***"
& $stsadm_path -o activatefeature -name $feature -url $url -force
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
ECHO "*****************************"
ECHO "*** Contoso.CashMoneyMillionaires ***"
ECHO "*****************************"
$solution = "Contoso.CashMoneyMillionaires.wsp"
ECHO "*** add the solution ***"
& $stsadm_path -o addsolution -filename $solution
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
ECHO "*** deploy the solution ***"
& $stsadm_path -o deploysolution -name $solution -immediate -allowgacdeployment -url $url -force
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
$feature = "Contoso.CashMoneyMillionaires"
ECHO "*** activate feature(s) ***"
& $stsadm_path -o activatefeature -name $feature -url $url -force
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
ECHO "************************************"
ECHO "*** Contoso.DollaDollaBill ***"
ECHO "************************************"
$solution = "Contoso.DollaDollaBill.wsp"
ECHO "*** add the solution ***"
& $stsadm_path -o addsolution -filename $solution
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
ECHO "*** deploy the solution ***"
& $stsadm_path -o deploysolution -name $solution -immediate -allowgacdeployment -url $url -force
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
$feature = "Contoso.DollaDollaBill"
ECHO "*** activate feature(s) ***"
& $stsadm_path -o activatefeature -name $feature -url $url -force
if ($? -eq $false) { exit }
ECHO "*** execute admin jobs ***"
& $stsadm_path -o execadmsvcjobs
if ($? -eq $false) { exit }
ECHO "************************"
ECHO "*** IIS APPPOOL MGMT ***"
ECHO "************************"
ECHO "*** query wmi for apppool ***"
$appPoolName = "SharedServices1"
$appPool = get-wmiobject -namespace "root\MicrosoftIISv2" -class "IIsApplicationPool" | Where-Object {$_.Name -eq "W3SVC/APPPOOLS/$appPoolName"}
if ($? -eq $false) { exit }
ECHO "*** recycle apppool ***"
$appPool.Recycle()
if ($? -eq $false) { exit }
I have an equivalent batch file that also fails randomly. It doesn't work on different servers. I am completely confused about the cause and the solution.
Any help would be appreciated.
source to share
The best I have found is to have the Power Shell wait for the timer job to complete before moving on to the next task, you can but pause, however this requires you to check to make sure the running time is complete.
The trick is to poll the server using stsadm -o displayolution -name. if wsp is installed in the farm, the command will return some xml, if there is a timer job for deployment, there is a "SolutionDeploymentJob" tag in the xml. With a simple loop, you can wait for the time job to end.
Function WaitForJobOn ($ name) {
[xml] $ val = stsadm -o displaysolution -name $ name
while ($ val.Solution.SolutionDeploymentJob) {
$ log.Info ("waiting for a job on $ name")
sleep 5
[xml] $ val = stsadm -o displaysolution -name $ name
}
$ log.Info ("Job Compleated")
}
using:
WaitForJobOn somefeature.wsp
it should be noted that the function will fail if wsp is not added to the farm.
source to share
I am also facing this problem. The only way I have come across is to restart the Windows SharePoint Services Admin Service every time before deploy / drop.
UPDATE: I rebooted the WFE server and this problem went away. I wish I had more information on why, but the classic Microsoft reboot solution prevails again.
This is very annoying.
ANOTHER UPDATE: I just released a stsadm command called smartexecjobdefs that fixes this problem. In this blog post, I will talk about the Job Definition Runner, which monitors the completion of work orders before taking back control. This stsadm command just brings this class over.
source to share
You need to pause between deploying your solution and trying to activate your features - this is a bit of a racing situation.
Optional: If there are multiple web interfaces, and the connection is slow, or the servers are busy, or any number of other things that make things like this take some time, then you run into problems. Batch files can't handle this - the Powershell script can use the Object Model to check if the solution is actually deployed before moving on.
source to share
I also had this problem. Every time I tried to deploy the solution, some of the files were copied and it stopped with this error before copying all of them. I don't have any proof, but I believe that the antivirus software on the server was blocking the files and interfering.
It ended up working after I tried to deploy the solution multiple times (copying more files each time than before).
source to share
I found that the Windows SharePoint Administration Service (SPAdmin) randomly fails in sp1 when used in a SharePoint farm with multiple frontend servers.
I suggest disabling spadmim and running stsadm -o execadmsvcjobs with a remote execution tool like psexec.
Example:
psexec.exe @ serverlist.txt "C: \ Program Files \ Common Files \ Microsoft Shared \ Web Server Extensions \ 12 \ BIN \ stsadm.exe" -o execadmsvcjobs
source to share