Error when removing an option from a select list custom field
Symptoms
When trying to remove an option from a select list custom field, an error screen is displayed by JIRA.
The following appears in the Technical Details of that error, and also in atlassian-jira.log
:
2014-01-31 16:56:30,583 http-bio-10617-exec-19 ERROR admin 1016x557x1 187l96b 0:0:0:0:0:0:0:1%0 /secure/admin/EditCustomFieldOptions!remove.jspa [webwork.util.ValueStack] query="affectedIssues/size" {[id="affectedIssues" type="8" values=""]} {[id="size" type="8" values=""]}
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
...lots of lines...
Caused by: java.lang.NullPointerException
at com.atlassian.jira.issue.context.ProjectContext.<init>(ProjectContext.java:49)
at com.atlassian.jira.issue.fields.config.manager.FieldConfigSchemeManagerImpl.getRelevantConfigScheme(FieldConfigSchemeManagerImpl.java:321)
at com.atlassian.jira.issue.fields.config.manager.FieldConfigSchemeManagerImpl.getRelevantConfig(FieldConfigSchemeManagerImpl.java:292)
at com.atlassian.jira.issue.fields.CustomFieldImpl.getRelevantConfig(CustomFieldImpl.java:637)
at com.atlassian.jira.issue.fields.CustomFieldImpl.getRelevantConfig(CustomFieldImpl.java:644)
... 274 more
Diagnosis
Run the below SQL to detect corrupt entries in the datbase:
select cfv.* from customfieldvalue cfv
left join jiraissue ji on (cfv.issue = ji.id)
where ji.id is null;
If any rows are returned, you are affected by this issue.
Cause
There are some assignments of the custom field value to issues which no longer exist. When JIRA tries to delete the custom field value, it fails when looking for the missing issue which the custom field is assigned to. We're not sure how to reproduce this with the JIRA UI, however this could occur due to issues being removed via SQL.
Resolution
Always back up your data before performing any modification to the database. If possible, try your modifications on a test server.
- Stop JIRA
Run the below sql to remove all the affected issues
delete from customfieldvalue where id in ( select cfv.id from customfieldvalue cfv left join jiraissue ji on (cfv.issue = ji.id) where ji.id is null);
- Start JIRA