Opening the Users view within the Confluence admin console results in a NullPointerException

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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

Summary

When an administrator opens the View All Users page, Confluence displays a NullPointerException to the UI and records an error in the application log. 

Examples of this include the following error messages:

2016-02-01 10:04:31,955 ERROR [http-nio-80-exec-5] [atlassian.confluence.servlet.ConfluenceServletDispatcher] sendError Could not execute action
 -- referer: http://URL/admin/users/showallusers.action?reset=true | url: /admin/users/showallusers.action | userName: admin007
java.lang.NullPointerException
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:187)
	at com.google.common.collect.ImmutableList$Builder.add(ImmutableList.java:583)
	at com.google.common.collect.ImmutableList$Builder.add(ImmutableList.java:566)
	at com.google.common.collect.ImmutableCollection$Builder.addAll(ImmutableCollection.java:324)
	at com.google.common.collect.ImmutableList$Builder.addAll(ImmutableList.java:600)
	at com.atlassian.confluence.api.model.pagination.PageResponseImpl$Builder.addAll(PageResponseImpl.java:189)
	at com.atlassian.confluence.api.model.pagination.PageResponseImpl.from(PageResponseImpl.java:94)
	at com.atlassian.confluence.api.impl.pagination.PaginationServiceImpl.lambda$doRequestInTransaction$385(PaginationServiceImpl.java:146)
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:128)
	at com.atlassian.confluence.api.impl.pagination.PaginationServiceImpl.doRequestInTransaction(PaginationServiceImpl.java:141)
	at com.atlassian.confluence.api.impl.pagination.PaginationServiceImpl.doPaginationRequest(PaginationServiceImpl.java:63)
	at com.atlassian.confluence.internal.user.UserSearchServiceInternalImpl.doUserSearch(UserSearchServiceInternalImpl.java:76)
	at com.atlassian.confluence.user.actions.AbstractSearchCrowdUsersAction.doUserSearch(AbstractSearchCrowdUsersAction.java:109)
	at com.atlassian.confluence.user.actions.BrowseUsersAction.execute(BrowseUsersAction.java:11)
...
2017-01-20 09:00:30,672 ERROR [http-nio-8090-exec-270] [atlassian.confluence.servlet.ConfluenceServletDispatcher] sendError Could not execute action
 -- referer: https://confluence.test.com/admin/plugins/lucidchart/configure.action | url: /admin/plugins/lucidchart/users.action | traceId: 42b48931e6993fdb | userName: admin007
java.lang.NullPointerException: Unable to find user mapping for test_user
    at com.atlassian.confluence.user.DefaultPersonalInformationManager.getOrCreatePersonalInformation(DefaultPersonalInformationManager.java:66)
    at com.atlassian.confluence.user.DefaultPersonalInformationManager.getPersonalInformation(DefaultPersonalInformationManager.java:54)
    at sun.reflect.GeneratedMethodAccessor2980.invoke(Unknown Source)

Environment

Confluence DC

Diagnosis

First Diagnosis SQL Statement

To find the record(s) causing this issue, let's first confirm whether there are null values or inconsistent values within the USER_MAPPING table:

Diagnosis SQL queries
SELECT * FROM user_mapping WHERE username IS NULL OR lower_username IS NULL OR lower_username NOT LIKE lower(username); 

If any records return by this SQL statement, execute the appropriate SQL Update command to populate the missing or inconsistent value. If help is needed with this, please open a case with the Atlassian Support team.

Second Diagnosis SQL Statement

If no records return, let's then check that every user in the CWD_USER table has a corresponding entry within the USER_MAPPING table and that there are no null values for username in the CWD_USER table:

SELECT * FROM cwd_user WHERE user_name not in (select username from user_mapping);
SELECT * FROM cwd_user WHERE lower_user_name not in (select lower_username from user_mapping where lower_username is not null);
SELECT * FROM cwd_user WHERE user_name is null or lower_user_name is null;

Third Diagnosis SQL Statement

Please check the logs and attempt to identify the search term parameter to understand which user triggered the Null Pointer Exception. For instance:

--------------------------
Parameters
--------------------------
searchTerm : username
showUnlicensedUsers : true
caused by: java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:903)

Based on the above search term, execute the following SQL query to retrieve user details from the 'cwd_user' and 'user_mapping' tables:

select * from cwd_user where user_name like '%username%'; 
select * from user_mapping where username like '%username%'; 

If any record is missing or if there's any discrepancy in the result, it may cause issues, and Confluence will be unable to identify the correct user, resulting in a Null Pointer Exception.

Cause

This issue occurs when there's a missing or incomplete user record within the USER_MAPPING table.  This situation can occur for any number of reasons:

  • A corruption in a cache. 
  • A corruption in an index. 
  • A corruption involving an external user directory.
  • A corruption at the database level.

Resolution  

If the second set of diagnosis SQL statements return no result

If the SQL statements above don't return any results, then try clearing the Confluence Cache Statistics and/or re-indexing: 

  1. First, try flushing the Cache Statistics: 
    1. Click on  >  General Configuration > Cache Management
    2. On the resulting page, click the Flush All button.
  2. If the problem persists, rebuild the indexes from within the UI:
    1. Click on  >  General Configuration > Content Indexing.
    2. Click Rebuild button.
  3. If the problem still occurs, then rebuild the content indexes from scratch

If the second set of diagnosis SQL statements return results

If records do return from the second SQL statements,  then proceed as follows depending on the kind of directory in use for user management.

When using an external LDAP directory

If an external LDAP directory is utilised and the connector for this service is configured with:

If you have activated the option of Read only with Local groups in your User Directory, the modifications below may cause a loss of local group management. 

Please, export the output of the following SQL statement into a TXT or CSV format, in order to have a copy of the Local Groups currently configured: 

SELECT * FROM CWD_GROUP WHERE local = 'T' AND directory_id = '<EXTERNAL_DIRECTORY_ID';


  1. Create a backup of the Confluence database.
  2. If you haven't already done so, log into Confluence as a admin user from the Internal Directory.
  3. Click on General Configuration > User Directories
  4. Locate the directory for the user who has a missing USER_MAPPING table entry.
  5. Do note the configuration of this User Directory's connector
    • (info) This can be done by manually noting its settings or taking screen shots of the configuration)
  6. Disable the directory in question and then remove it.  
    • (info) This will cause Confluence to remove user entries for that directory from CWD_USER table.
  7. Create a new directory connector using the same directory configuration as noted in the previous step.  
    • (info) This will cause Confluence to re-insert users the CWD_USER.
  8. Now, test the Users page to check if it renders as expected.

If you still find a specific user that the record in the USER_MAPPING table is missing, you can repopulate the data manually. If you don't know the actual user_key of this user, you can find it using the page ID of one of the pages created or modified by this user: 

SELECT * FROM user_mapping 
WHERE user_key = (SELECT creator FROM CONTENT WHERE id='<PAGEID>')
OR user_key = (SELECT lastmodifier FROM CONTENT WHERE id='<PAGEID>')

Once the user_key is found, you can just INSERT the record manually in the USER_MAPPING table as follows: 

INSERT INTO user_mapping values ('2c9681954172cf560000000000000001', 'test_user', 'test_user');
INSERT INTO user_mapping values ('2c9681954172cf560000000000000001', 'test_user', 'test_user');



When using an Internal Directory

If an Internal Directory is utilised and the user in question belongs to this directory:

  1. Create a backup of the Confluence database.
  2. Shut down Confluence.
  3. For each affected user, INSERT values manually into the database: 

    INSERT INTO user_mapping values ('2c9681954172cf560000000000000001', 'test_user', 'test_user');
    INSERT INTO content ("contentid", "contenttype", "version", "content_status", "username") VALUES (9999999, 'USERINFO', 1, 'current', '2c9681954172cf560000000000000001');
    INSERT INTO user_mapping values ('2c9681954172cf560000000000000001', 'test_user', 'test_user');
    INSERT INTO content (contentid, contenttype, version, content_status, username) VALUES (9999999, 'USERINFO', 1, 'current', '2c9681954172cf560000000000000001');
  4. Restart Confluence.


In case of issues or concerns to follow this procedure, please reach out to the Atlassian Support team and share the information that's been gathered so far along with a fresh Support zip file.


Last modified on May 14, 2024

Was this helpful?

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