Unable to delete user due to NullPointerException

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

When trying to delete an user, the following error appears in the atlassian-jira.log:

2012-11-19 14:23:20,749 http-bio-8081-exec-7 ERROR xxxxxx 
863x987x1 122bk0 10.174.20.19 /secure/admin/user/DeleteUser.jspa [jira.user.util.UserUtilImpl] There was an error trying to remove user: xxxxxx

java.lang.NullPointerException
        at com.atlassian.jira.sharing.index.DefaultSharedEntityIndexer$DefaultEntityDocumentFactory$1.<init>(DefaultSharedEntityIndexer.java:173)
        at com.atlassian.jira.sharing.index.DefaultSharedEntityIndexer$DefaultEntityDocumentFactory.get(DefaultSharedEntityIndexer.java:171)
        at com.atlassian.jira.sharing.index.DefaultSharedEntityIndexer.index(DefaultSharedEntityIndexer.java:71)
        at com.atlassian.jira.issue.search.DefaultSearchRequestManager.adjustFavouriteCount(DefaultSearchRequestManager.java:277)
        at com.atlassian.jira.favourites.DefaultFavouritesManager.adjustFavouriteCount(DefaultFavouritesManager.java:65)
        at com.atlassian.jira.favourites.DefaultFavouritesManager.removeFavourite(DefaultFavouritesManager.java:75)
        at com.atlassian.jira.favourites.DefaultFavouritesManager.removeFavouritesForUser(DefaultFavouritesManager.java:106)
        ...

Cause

This error is caused by associations between users and filters/dashboards that no longer exist. The following SQL queries will return the rows from the favouriteassociations table that link to entries that no longer exist in the searchrequest and portalpage tables:

select * from favouriteassociations where entitytype = 'SearchRequest' and entityid not in (select id from searchrequest);

AND

select * from favouriteassociations where entitytype = 'PortalPage' and entityid not in (select id from portalpage);

Resolution

  1. Create an XML backup as it is always recommended before any database modification
  2. Shutdown your JIRA instance
  3. Run the following query on your database (this will delete any invalid associations)

    delete from favouriteassociations where entitytype = 'SearchRequest' and entityid not in (select id from searchrequest);
    
    delete from favouriteassociations where entitytype = 'PortalPage' and entityid not in (select id from portalpage);
    
  4. After you run the above query, you can check whether the invalid associations have been removed by running the following query

    select * from favouriteassociations WHERE USERNAME = 'type_username_here';
    
  5. If the result is zero(0), then you can start JIRA again, and then re-index your JIRA instance

Last modified on Nov 19, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.