Viewing Team Calendars for Confluence result in 500 error
Platform Notice: Server, Data Center, and Cloud By Request - This article was written for the Atlassian server and data center platforms but may also be useful for Atlassian Cloud customers. If completing instructions in this article would help you, please contact Atlassian Support and mention it.
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.
*Fisheye および Crucible は除く
問題
When attempting to view Team Calendars for Confluence, users receive a 500 error as shown below:
atlassian-confluence.log
に次のメッセージが出力される。
2015-07-26 02:31:28,532 ERROR [http-8080-exec-997] [common.error.jersey.ThrowableExceptionMapper] toResponse Uncaught exception thrown by REST service
-- url: /confluence/rest/calendar-services/1.0/calendar/search/subcalendars/all | userName: admin | referer: http://localhost:8090/confluence/calendar/mycalendar.action
java.lang.NullPointerException
at com.atlassian.confluence.extra.calendar3.rest.SubCalendarsResponseEntity$ExtendedSubCalendar$PermittedUserComparator.compare(SubCalendarsResponseEntity.java:574)
at com.atlassian.confluence.extra.calendar3.rest.SubCalendarsResponseEntity$ExtendedSubCalendar$PermittedUserComparator.compare(SubCalendarsResponseEntity.java:569)
at java.util.TimSort.binarySort(TimSort.java:265)
at java.util.TimSort.sort(TimSort.java:190)
at java.util.TimSort.sort(TimSort.java:173)
at java.util.Arrays.sort(Arrays.java:659)
at java.util.Collections.sort(Collections.java:217)
at com.google.common.collect.ComparatorOrdering.sortedCopy(ComparatorOrdering.java:51)
at com.atlassian.confluence.extra.calendar3.rest.SubCalendarsResponseEntity$ExtendedSubCalendar.getUsersPermittedToEdit(SubCalendarsResponseEntity.java:355)
at com.atlassian.confluence.extra.calendar3.rest.SubCalendarsResponseEntity$ExtendedSubCalendar.toJson(SubCalendarsResponseEntity.java:428)
at com.atlassian.confluence.extra.calendar3.rest.SubCalendarsResponseEntity.toJson(SubCalendarsResponseEntity.java:79)
at com.atlassian.confluence.extra.calendar3.rest.CalendarResource$26.doInTransaction(CalendarResource.java:1838)
at com.atlassian.confluence.extra.calendar3.rest.CalendarResource$26.doInTransaction(CalendarResource.java:1793)
at com.atlassian.sal.core.transaction.HostContextTransactionTemplate$1.doInTransaction(HostContextTransactionTemplate.java:25)
at com.atlassian.sal.spring.component.SpringHostContextAccessor$1.doInTransaction(SpringHostContextAccessor.java:88)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:128)
診断
The above stacktrace came from Team Calendars for Confluence 4.3.13 and the related source code indicates that it was doing an user comparison for sub-calendar restrictions:
ソース コード
private static class PermittedUserComparator implements Comparator<PermittedUser>
{
@Override
public int compare(PermittedUser leftUser, PermittedUser rightUser)
{
int result = leftUser.getFullName().compareTo(rightUser.getFullName()); //line 574 NPE
if (0 == result)
result = leftUser.getId().compareTo(rightUser.getId());
return result;
}
原因
- When viewing Team Calendars for Confluence, it makes a check for view and edit restrictions. During this check, it hits a NPE indicating that an user reference does not exist.
- A second scenario may occur relating to subscriptions, see here: TEAMCAL-1759 - Getting issue details... STATUS
ソリューション
Backup the database before attempting any of the below instructions
Identify the reference that may be pointing at an non-existent user:
select * from "AO_950DC3_TC_SUBCALS_PRIV_USR" c left join user_mapping u on c."USER_KEY"=u.user_key where lower_username not in (select lower_user_name from cwd_user);
- Any results returned are restrictions set for users that do not exist in the user listing
- Any results returned are restrictions set for users that do not exist in the user listing
Remove the restriction references
AO_950DC3_TC_SUBCALS_PRIV_USR
delete from "AO_950DC3_TC_SUBCALS_PRIV_USR" where "ID" = XXXXX; Replace XXXXX with the proper ID returned from the first SQL query.
- Flush Confluence's caches: Confluence Admin > Administration > Cache Statstics > Flush All