Viewing Team Calendars for Confluence result in 500 error

Still need help?

The Atlassian Community is here for you.

Ask the community

 

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.

*Except Fisheye and Crucible

Problem

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

The following appears in the 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)

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

       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:  TEAMCAL-1759 - Getting issue details... STATUS

Resolution

Backup the database before attempting any of the below instructions

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

    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

 

Last modified on Mar 30, 2016

Was this helpful?

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