NullPointerException when Deleting a Custom Field
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server 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
Symptoms
When creating or updating an issue, the following error is thrown in JIRA:
When trying to delete a custom field, the custom field cannot be removed. The stacktrace will appear as following in the JIRA log files:
java.lang.NullPointerException
at com.atlassian.jira.issue.customfields.persistence.OfBizCustomFieldValuePersister.removeAllValues(OfBizCustomFieldValuePersister.java:180)
at com.atlassian.jira.issue.customfields.persistence.EagerLoadingOfBizCustomFieldPersister.removeAllValues(EagerLoadingOfBizCustomFieldPersister.java:62)
at com.atlassian.jira.issue.customfields.impl.AbstractSingleFieldType.remove(AbstractSingleFieldType.java:106)
at com.atlassian.jira.issue.fields.CustomFieldImpl.remove(CustomFieldImpl.java:649)
at com.atlassian.jira.issue.managers.DefaultCustomFieldManager.removeCustomField(DefaultCustomFieldManager.java:374)
at com.atlassian.jira.web.action.admin.customfields.DeleteCustomField.doExecute(DeleteCustomField.java:34)
at webwork.action.ActionSupport.execute(ActionSupport.java:153)
...
(more)
Cause
The database is corrupted. There is a custom field value associated to a 'NULL' issue.
Resolution
Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
- Stop JIRA
Perform the following SQL query to check whether there are any custom fields assigned to 'NULL' issue. You should get
select * from customfieldvalue where ISSUE is null; +-------+-------+-------------+-----------+------------------+-------------+-----------+-----------+-----------+ | ID | ISSUE | CUSTOMFIELD | PARENTKEY | STRINGVALUE | NUMBERVALUE | TEXTVALUE | DATEVALUE | VALUETYPE | +-------+-------+-------------+-----------+------------------+-------------+-----------+-----------+-----------+ | 36625 | NULL | 10000 | NULL | Field value | NULL | NULL | NULL | NULL | +-------+-------+-------------+-----------+------------------+-------------+-----------+-----------+-----------+ 1 row in set (0.00 sec)
Remove the custom field value:
delete from customfieldvalue where issue is null;
- Restart JIRA