Wednesday, September 17, 2008

Windows Search Server (SharePoint): An unexpected error has occurred.

I have a sort of a „Love/Hate“ relationship with SharePoint. I like the product because I think it offers a lot you can do with it, but I hate it when it comes to troubleshooting.

This time, I have setup Windows Search Server 2008 and it works just perfectly on our site. I then gave the URL to somebody else from a different site and he only got An unexpected error has occurred. Great, here we go again.

The first thing is to turn on real error messages, not this stupid “Something went wrong, but I won’t tell you”.

To do so, open the web.config file for your site. For a default installation, this file will be located at C:\Inetpub\wwwroot\wss\VirtualDirectories\80. Open it in Notepad and search for customErrors mode="On". Replace it with customErrors mode="Off". To get more details, we will also turn on the call stack (in which procedure the error is actually happening). Search for CallStack=”false” and change it to CallStack="true" (this is in the SafeMode section).

Once we have done this, we were getting (somewhat) more detailed error messages:

Object reference not set to an instance of an object.

[NullReferenceException: Object reference not set to an instance of an object.] Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart.OnLoad(EventArgs e) +94 System.Web.UI.Control.LoadRecursive() +65

On another machine we were getting this error:

Object reference not set to an instance of an object.

[NullReferenceException: Object reference not set to an instance of an object.] Microsoft.Office.Server.Administration.SqlSessionStateResolver.System.Web.IPartitionResolver.ResolvePartition(Object key) +77

The server was also now logs a lot of ASP.NET errors 1309 into the Application event log. Somehow I cam across a post from Chinmay Vartak showing the same error message (but for a different problem) and the steps he pointed out were the solution.

The problem was that on the remote site the name of the server was resolvable, but pointed to a wrong IP address. Although we were using a FQN (http://servername.site.acme.com instead of just http://servername) to access the server, internally WSS was not using the FQN but just the server name. So, all you need to do is to tell SharePoint to always use the FQN.

To do this, go to the Central Administration of the server and select Operations -> Alternate access mappings

Click on Edit Public URLs and change the entry for Default to be a FQN and click on Save.

In case you want to use SSL (https) also, you will need to create an entry for this also by using Add internal URLs and enter the https FQN URL for this server. When you have done this also, Alternate access mappings should show a list similar to this one:

Now all this stupid errors should be gone and everyone can access your server with either http or https.

Enjoy!

5 comments:

  1. I got the same exception when trying to call a SharePoint application page (the ones in /_layouts) from Microsoft Dynamics CRM.
    Followed the steps and it worked!!! No exception no more.

    Thank you so much Tex Hex.

    ReplyDelete
  2. I got the same exception when trying to call a SharePoint application page (the ones in /_layouts) from Microsoft Dynamics CRM.
    Followed the steps and it worked!!! No exception no more.

    Thank you so much Tex Hex.

    ReplyDelete
  3. Thanks for informatory page..my problem is different, but I got an idea to reach to the problem by disabling customerror mode.

    ReplyDelete
  4. Excellent...it worked for me!!

    ReplyDelete