Saturday, October 20, 2007

No Web parts Found.. while adding the webparts

Problem Definition:

After creating a '.stp' file out of a site, and adding this .stp template to a farm using stsadm, when you try to add webparts to the new site collection that has been created with the custom site template, you will get the error ''No Web parts Found.."



Fix:

  1. You can manually copy the webparts from the tempalte site webpart gallery and paste into the destination webpart gallery. But web parts are not grouped in sections(Content Rollup, dashboard, mislaneous, all webparts etc)
  2. You can also go to the new site webpart gallery and populate the webparts manually.
    (Site Actions -> Site Settings -> Galleries -> Webpart Gallery -> New -> select the webpart you desire -> populate)
  3. Run the following code using a console application if you wish to add the webparts only once. If you are running like this, then uncomment the line 'SPSite ProvisionedSite = new SPSite(provisionedSiteUrl);' and comment the line 'SPSite ProvisionedSite = SPContext.Current.Site;'

    If you wish to have the webparts copied automatically, each time you create a site, then go for a feature and embed this code in the 'Feature_Acticated' method of the feature.
//code for copying webpart files from the template site to provisioned site
public static void CopyWebParts(string templateSiteUrl, string provisionedSiteUrl)
{
// Get the context of the template site
SPSite templateSite = new SPSite(templateSiteUrl);
// Access the Template site Webparts folder under _catalogs
SPFileCollection templateWebParts = templateSite.RootWeb.Folders["_catalogs"].SubFolders["wp"].Files;
// Below line is commented as this code is meant for automatic execution.Un comment this line, if you want to run this code as a console application.
//SPSite ProvisionedSite = new SPSite(provisionedSiteUrl);
// Load the properties of the existing file
// Get the current site context
SPSite ProvisionedSite = SPContext.Current.Site;
// Access the Provisioned site Webparts folder under _catalogs
SPFileCollection ProvisionedWebParts = ProvisionedSite.RootWeb.Folders["_catalogs"].SubFolders["wp"].Files;
foreach (SPFile templateWebPart in templateWebParts)
{
// Load the properties of the existing file
byte[] binaryData = templateWebPart.OpenBinary();
// Copy the file
SPFile copiedFile = ProvisionedWebParts.Add(templateWebPart.Name, binaryData, true);
copiedFile.Update();
// Update the properties of the copied file

copiedFile.Item["Group"] = templateWebPart.Item["Group"];
copiedFile.Item["Quick Add Groups"] = templateWebPart.Item["Quick Add Groups"];
copiedFile.Item.Update();
copiedFile.Update();
}
}
 
Note:Always activate features through the browser.
Do not activate this feature through command prompt stsadm.exe.
Coz, stsadm doesn’t know the current context of the site.

Saturday, October 13, 2007

Login failed for user 'Domain Name\

When you see the error ' Login failed for user 'Domain Name\<SharePoint Server Name>', follow the below command: 

STSADM.EXE -o provisionservice -action start -servicetype “Microsoft.Office.Excel.Server.ExcelServerSharedWebService, Microsoft.Office.Excel.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”

Friday, October 5, 2007

Sharepoint server is too busy

There are so many reasons for this issues, lets go over all the possible reasons and fixes.

Reason 1: Not enough CPU speed.
Fix: Add more CPUs to the existing one and upgrade the speed to at least 4 Ghz.

Reason 2:
Make sure that the server is NOTrunning in the debug mode. Usually dev and QA servers are enabled with debug mode for interactive trouble shooting. All production servers are supposed to run in the 'non-debug' mode. If you are running in the debug mode, all the intermediate variables and values are cached for the debugging purpose. If you have a single variable for a code block, never think that it is gonna be a single variable on the server. A copy of the variable gets created each time a user access the code. FIX:
Disabling the debug mode for all the asp.net applicationsGo to the machine.config located at the location:C:\Microsoft.NET\Framework\%VersionNumber%\CONFIG\Your compilation mode should look like this:
<compilation debug="false"/>

Disabling the debug mode for only the sharepoint C:\Inetpub\wwwroot\wss\VirtualDirectories\80 and open the web.config(This path is for the default 80 port. If your application is running on other ports do this for all the other ports)Your compilation mode should look like this:
<compilation batch="false" debug="false">



Reason 3: Sharepoint master page or any custom page accessing asp code. Eg, IFrame rendering .asp file. This problem occurs if you have sp1 on 2003 server and do not have sp2.
Microsoft included this hot fix in the sp2.

Fix: Microsoft has hot fix to correct this problem.
http://support.microsoft.com/kb/916984

http://support.microsoft.com/kb/188352

Reason 4: Full Crawl tries to authenticate the users.
Fix:

On the application server,

  1. This is for the general sharepoint server slow.
    start - > Run -> regedit -> HKEY_LOCAL_MACHINE\Software\Microsoft\Shared Tools\web server extensions\12\WSS
    right click on the WSS -> permissions -> Add user/group -> Everyone -> Read access
  2. This is for the Full Crawl/Incremental crawl causing server slow
    start - > Run -> regedit -> HKEY_LOCAL_MACHINE\Software\Microsoft\Shared Tools\web server extensions\12\Search
    right click on the Search -> permissions -> Add user/group -> Everyone -> Read access
Reason 5:
Network Traffic increase.

Fix:

If your website keeps growing and growing, eventually you will hit the error 500-13, that your server is too busy to handle the requests. What do you do?

First, check your main settings in IIS. Make sure you look in the PERFORMANCE tab. Set your site to more than 100,000 hits/day which is probably true if you are running into this error. Remember that hits includes every file you send out - including graphics - and is much larger than your page view count.

On that same page, be sure to turn off bandwidth throttling and process throttling.

Next, on your main entry in your IIS manager, right click to get properties. Go into Server Extensions - Settings. Depending on your use of include files and images, you may want to increase the cache sizes there.

To monitor the issue, open the performance monitor in your control panel. Right click on the lower right area to add a new item to monitor. You should add in -

ASP - requests queued
ASP - requests executing
ASP - script engines cached
Processor - % processor time
Memory - available bytes

I highly recommend using XCompress which is an ASP compressor, helping to ensure that you use as little bandwidth as possible in sending your ASP files out to end users.

If you want to take your life into your own hands, you can also try setting the cache settings manually. You need to launch a CMD prompt first. Head into inetpub\adminscripts. Then run commands:

adsutil set w3svc/1/AspQueueTimeout 30
adsutil set w3svc/1/ServerListenBackLog 500
adsutil set w3svc/1/MaxEndPointConnections 500

Those will help reduce your timeout from its unlimited initial state, and set higher limits on the backlog and max connections values. Be sure to backup before trying this!

In addition, you can go back into the IIS manager and right click for the properties. Go into Home Directory then Configuration. You get a special tab in here for Process Options that is not available on a single-website basis. Set the cache values up high enough based on the performance monitor entries.

Reason 6:
Script errors on the pages running under the server. To fix this issue, look for all the script errors by the 'err' object to diagnose. Also look whether they are leaving any un allocated objects in the stack.