Viewing Team Calendars for Confluence result in 500 error

Platform Notice: Cloud and Data Center - This article applies equally to both cloud 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

Problem

When attempting to view Team Calendars for Confluence, users receive a 500 error as shown below:

(Auto-migrated image: description temporarily unavailable)

The following appears in the atlassian-confluence.log

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 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)

Diagnosis

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:

Source Code

1 2 3 4 5 6 7 8 9 10 11 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; }

Cause

  1. 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.

  2. A second scenario may occur relating to subscriptions, see here: CONFSERVER-49812 - Error 500 - subcalendar

Solution

Resolution

Backup the database before attempting any of the below instructions

  1. Identify the reference that may be pointing at an non-existent user:

    1 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);
    1. Any results returned are restrictions set for users that do not exist in the user listing

  2. Remove the restriction references AO_950DC3_TC_SUBCALS_PRIV_USR

    1 2 3 delete from "AO_950DC3_TC_SUBCALS_PRIV_USR" where "ID" = XXXXX;   Replace XXXXX with the proper ID returned from the first SQL query.
  3. Flush Confluence's caches: Confluence Admin > Administration > Cache Statstics > Flush All

Updated on April 2, 2025

Still need help?

The Atlassian Community is here for you.