Friday, November 5, 2010

STSADM - Object reference not set to instance of an object

I know this is the error which developers see most of the times. This is very basic error and it raises when we tried to access NULL reference object. But, What is if it comes while accessing STSADM? In SharePoint everyone knows the role of STSADM and the advantage of it. If you try to do some operation using STSADM tool and ends with the error "Object reference not set to instance of an object" then it is very difficult to trace as it is not giving us the enough information. But, with the experience, we get some ideas and solutions. Most of us know the resolution but I want to place everything what I know to my readers on this blog.

Resolution:
The user who runs the STSADM on the server should have access to the SharePoint Admin content database. If he don't have access, but he is administrator on server, has full access to central administration and farm administrator access then still no use. He should have access to the admin content database. Because whatever we do using STSADM then it is indirectly dealing with database only. So, user logged in should have access to database.

This is one of the main thing which we need to remember in administration side. Hope you liked it and you remember it forever. And mainly this scenario will come on environment where the farm server setup and database server is different from SharePoint server.

14 comments:

  1. I am getting error like :
    FatalError: Object reference not set to an instance of an object.
    at Microsoft.SharePoint.Deployment.ContentTypeSerializer.GetContentType(SPCon
    tentType sourceContentType, ImportObjectManager importObjectManager, Boolean isP
    arentSystemObject)
    at Microsoft.SharePoint.Deployment.ContentTypeSerializer.ProcessContentType(S
    PContentType sourceContentType, String contentTypeXml, ImportObjectManager impor
    tObjectManager, Boolean IsParentSystemObject)
    at Microsoft.SharePoint.Deployment.ContentTypeSerializer.SetObjectData(Object
    obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selec
    tor)
    at Microsoft.SharePoint.Deployment.XmlFormatter.ParseObject(Type objectType,
    Boolean isChildObject)
    at Microsoft.SharePoint.Deployment.XmlFormatter.DeserializeObject(Type object
    Type, Boolean isChildObject, DeploymentObject envelope)
    at Microsoft.SharePoint.Deployment.XmlFormatter.Deserialize(Stream serializat
    ionStream)
    at Microsoft.SharePoint.Deployment.ObjectSerializer.Deserialize(Stream serial
    izationStream)
    at Microsoft.SharePoint.Deployment.ImportObjectManager.ProcessObject(XmlReade
    r xmlReader)
    at Microsoft.SharePoint.Deployment.SPImport.DeserializeObjects()
    at Microsoft.SharePoint.Deployment.SPImport.Run()


    Any suggestion will be helpfull

    ReplyDelete
  2. Please check once the access to the Configuration and sharepoint admin content databases for the account you logged in to the server. 99% of this issue comes only because of access issue.

    ReplyDelete
  3. I'm getting the error mentioned in the subject of this thread. What type of 'access' needs to be given? Thanks.

    ReplyDelete
  4. Hi George,
    As I have mentioned, you should have access to the SharePoint database as SharePoint stores all the data, configuration in the database. So, to proceed to make any changes or do some stuff using STSADM you should need database access. Let me know if you have any more question.

    ReplyDelete
  5. Forgive my ignorance but I don't know what 'access to the SharePoint database' means. I'm in SQL Server Management and see my WSS Content database and also the user that I need to grant access to but what needs to be granted & where? Thanks SO much!

    ReplyDelete
  6. Hi George,
    The user should need full access to database. [Owner] and on the SharePoint server he should be an administrator. So, in simple words the user who needs access to do some operation using STSADM should grant access to both SharePoint server and SharePoint admin content databases. Let me know if that didn't answer your question.

    The access to a database will grant through SSMS [Sql Server Management Studio]. So, expand Security, Logins under the server instance and find the user if exists and set his permissions from that window. If user not in the list then add him to the list. Good luck.

    ReplyDelete
  7. Thanks for your help! I must be missing something as I'm still getting the error. I found the user, selected Properties & then granted db_owner rights under User Mappings. Is this the correct spot?

    ReplyDelete
  8. Can you show the exact permissions. I am still getting the same error regardless of what I do.

    ReplyDelete
  9. Hi... it works fine if i use the stsadm for document library but NOT for Infopath form library. Any ideas? I get the same error. I'm using an admin account which has all the permissions.
    Thanks!

    ReplyDelete
  10. Hi, re-connection of config database helped to me. ;)

    ReplyDelete
  11. Thank you Praveen. Also an additional tip for some - I initially gave myself db_owner permissions for our main database but still had the error. I then tried the content database and it worked.

    ReplyDelete