Details
-
Bug
-
Resolution: Unresolved
-
Low
-
None
-
5.9.2, 5.9.9, 5.9.12
-
16
-
Severity 3 - Minor
-
4
-
Description
Summary
Users are not able to log in and searching for the user yields and NPE error because the user is not present in the user_mapping table.
Steps to Reproduce
We have not found full steps to reproduce yet, but have seen several instances of this.
- Run the following query against the database:
SELECT * FROM user_mapping where username = '<user name>';
Expected Results
User has an entry with the user_mapping table.
user_key | username | lower_username ----------------------------------+----------+---------------- 8a80808a549976be0154ab7b19440006 | admin | admin
While searching for this users in the user directory, the following error message is displayed:
Cause java.lang.NullPointerException at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:187) Stack Trace:[hide] 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$387(PaginationServiceImpl.java:146) at com.atlassian.confluence.api.impl.pagination.PaginationServiceImpl$$Lambda$238/516446270.doInTransaction(Unknown Source) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:128) at com.atlassian.confluence.api.impl.pagination.PaginationServiceImpl.doRequestInTransaction(PaginationServiceImpl.java:141) ...
You may also see these items in the atlassian-confluence.log
Caused by: java.lang.NullPointerException: Unable to find user mapping for <user name>
at com.atlassian.confluence.user.DefaultPersonalInformationManager.getOrCreatePersonalInformation(DefaultPersonalInformationManager.java:66)
at sun.reflect.GeneratedMethodAccessor858.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at com.atlassian.spring.interceptors.SpringProfilingInterceptor.invoke(SpringProfilingInterceptor.java:16)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
at com.sun.proxy.$Proxy78.getOrCreatePersonalInformation(Unknown Source)
at com.atlassian.confluence.user.crowd.UserIndexingListener.ensurePersonalInformationAndReindex(UserIndexingListener.java:165)
at com.atlassian.confluence.user.crowd.UserIndexingListener.onCrowdUserUpdatedEvent(UserIndexingListener.java:134)
at sun.reflect.GeneratedMethodAccessor1879.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:36)
... 51 more
Actual Results
User does not have an entry in the user_mapping table and you receive an empty result:
user_key | username | lower_username -------------------------------- (0 rows)
Workaround
Workaround 1: Finding the user_mapping key from a previous database backup and restoring it manually
- Restore a database dump to a new database or an old xml backup to a new instance
- Run the following SQL query against your restored database dump/restored instance to find the user mapping key for that user:
SELECT * FROM user_mapping WHERE username='<user name>';
- Then run this query against your instance to restore the user_key:
INSERT INTO user_mapping VALUES ('<user_key_from_previous_query>', '<user name>', '<user name>');
Workaround 2: Replacing the user_mapping entry with a new user_key
Please note that this workaround is not recommended and is provided for informational purposes. Userkeys need to be unique and generating them randomly can cause failures down the line. If you have any information regarding changes made to the user account prior to this issue appearing, please let us know.
- Use the following SQL query to add the entry manually:
INSERT INTO user_mapping VALUES ('2c9681954172cf560000000000000001', '<user name>', '<user name>');
- Note that both the <user name> above has to be in all lowercase
- Always back up your data before performing any modifications to the database. If possible, test any insert, update, or delete SQL commands on a staging server first.
Make sure that:
- Confluence is shut down before performing any changes to the database
- After performing the workarounds, Rebuild the Content Indexes from Scratch