Unable to delete user due to NullPointerException
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Symptoms
When trying to delete an user, the following error appears in the atlassian-jira.log
:
1
2
3
4
5
6
7
8
9
10
11
12
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:
1
select * from favouriteassociations where entitytype = 'SearchRequest' and entityid not in (select id from searchrequest);
AND
1
select * from favouriteassociations where entitytype = 'PortalPage' and entityid not in (select id from portalpage);
Resolution
Create an XML backup as it is always recommended before any database modification
Shutdown your JIRA instance
Run the following query on your database (this will delete any invalid associations)
1
delete from favouriteassociations where entitytype = 'SearchRequest' and entityid not in (select id from searchrequest);
1
delete from favouriteassociations where entitytype = 'PortalPage' and entityid not in (select id from portalpage);
After you run the above query, you can check whether the invalid associations have been removed by running the following query
1
select * from favouriteassociations WHERE USERNAME = 'type_username_here';
If the result is zero(0), then you can start JIRA again, and then re-index your JIRA instance
Was this helpful?