NullPointerException when removing CDN configuration using REST API
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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
A misconfiguration of the CDN or a CDN service outage may cause the application's UI to become inaccessible. When this happens, we must run a REST command to remove the data from Confluence database and allow the app to work correctly again.
As described in our CDN configuration guide, we can run this REST command if we are unable to remove the CDN from the Confluence UI:
curl -v -u <admin username>:<admin password> -X DELETE http://<your-base-url>/rest/static-asset-caching/configuration
Environment
Confluence Data Center using CDN (Content Delivery Network).
Diagnosis
The following error appears in the logs after running the REST API command to remove the CDN from Confluence.
ERROR [http-nio-8090-exec-3] [common.error.jersey.ThrowableExceptionMapper] toResponse Uncaught exception thrown by REST service: null
-- url: /rest/static-asset-caching/configuration | traceId: xxxxxxxxxxxxxx | userName: xxxxxxx
java.lang.NullPointerException
at com.atlassian.plugins.impl.rest.CdnConfigurationResource.delete(CdnConfigurationResource.java:74)
Cause
This issue is caused by missing data in the database, which is expected by the REST command. The Bandana table keeps the CDN records and if some of the data is missing, the error above may occur.
Workaround
We can remove the CDN configuration manually from the database and set the CDN setting to false using SQL commands.
Always backup the database before modifying or removing any data for safety reasons.
1) Shutdown Confluence on all nodes.
2) Run the following SQL commands on the Confluence database:
delete from BANDANA where bandanakey = 'atlassian.prefix.cdn.url';
update BANDANA set BANDANACONTEXT='_GLOBAL', BANDANAKEY='atlassian.cdn.enabled', BANDANAVALUE='<string>false</string>' where bandanakey = 'atlassian.cdn.enabled';
3) Start one node at a time. Wait for each node to come up before starting the next node.
4) Check on Confluence Administration > General Configuration > Content Delivery Network to verify that it is disabled.