Cast error when trying to configure default value in custom field

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

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.

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

Diagnosis

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';

Cause

Seems that the default value for the affected custom field has an invalid value on the genericconfiguration table.

Resolution

Perform a database backup, so this way you can prevent any data loss caused by a wrong manipulation on JIRA data.

  1. Shutdown JIRA.
  2. 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'
    

    (info) The field configuration id is the one get from the query mentioned on "Diagnosis" section on this article.

  3. Delete the returned results from query above.

Last modified on Nov 2, 2018

Was this helpful?

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