Cast error when trying to configure default value in custom field
症状
When attempting to edit the default value or the options for a custom field, a System error screen will appear and a cast exception is thrown.
atlassian-jira.log
に次のエラーが返される。
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long
at com.atlassian.jira.issue.customfields.impl.SelectCFType.getDefaultValue(SelectCFType.java:243)
at com.atlassian.jira.issue.customfields.impl.SelectCFType.getDefaultValue(SelectCFType.java:68)
at com.atlassian.jira.issue.fields.CustomFieldImpl.populateDefaults(CustomFieldImpl.java:554)
at com.atlassian.jira.issue.fields.screen.FieldScreenRenderLayoutItemImpl.populateDefaults(FieldScreenRenderLayoutItemImpl.java:92)
at com.atlassian.jira.issue.fields.rest.FieldHtmlFactoryImpl.getCreateFields(FieldHtmlFactoryImpl.java:86)
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)
診断
The default value for the affected custom field is stored under the genericconfiguration table. To discover which entry is related with the problematic custom field, we will need to first discover the field configuration id for this custom field. Therefore, please run the query below, replacing 'XXXXX' with the ID of the custom field.
SELECT * FROM fieldconfiguration WHERE fieldid = 'customfield_XXXXX';
If you are not sure about the custom field id that you need to look for on the query above, you might discover it upon running the query below. Please replace the query below with the custom field name and run it.
SELECT * FROM customfield WHERE cfname = 'AFFECTED CUSTOM FIELD NAME';
原因
Seems that the default value for the affected custom field has an invalid value on the genericconfiguration
table.
ソリューション
Perform a database backup, so this way you can prevent any data loss caused by a wrong manipulation on JIRA data.
- Jira をシャットダウンします。
Get the rows from
genericconfiguration
table which needs to be deleted. You can discover which entries must be deleted by running the following query:SELECT * FROM genericconfiguration WHERE datakey = 'ID OF FIELDCONFIGURATION ENTRY'
The field configuration id is the one get from the query mentioned on "Diagnosis" section on this article.
- Delete the returned results from query above.