Editing a Custom Field throws "cannot be cast to java.lang.String"

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

Symptoms

After ordering a search in the issue navigator by a custom field, or trying to edit the custom field configuration, JIRA throws the following error:

The following appears in the atlassian-jira.log:

1 2 3 4 5 6 7 8 9 10 java.lang.ClassCastException: com.atlassian.jira.issue.customfields.option.LazyLoadedOption cannot be cast to java.lang.String at com.atlassian.jira.issue.customfields.impl.SelectCFType.compare(SelectCFType.java:68) at com.atlassian.jira.issue.fields.CustomFieldImpl.compare(CustomFieldImpl.java:2015) at com.atlassian.jira.issue.fields.CustomFieldImpl$CustomFieldIssueSortComparator.compare(CustomFieldImpl.java:2103) at com.atlassian.jira.issue.search.parameters.lucene.sort.DefaultIssueSortComparator.compare(DefaultIssueSortComparator.java:37) at com.atlassian.jira.issue.search.parameters.lucene.sort.DocumentSortComparatorSource$InternalFieldComparator.compare(DocumentSortComparatorSource.java:72) at org.apache.lucene.search.FieldValueHitQueue$MultiComparatorsFieldValueHitQueue.lessThan(FieldValueHitQueue.java:125) at org.apache.lucene.search.FieldValueHitQueue$MultiComparatorsFieldValueHitQueue.lessThan(FieldValueHitQueue.java:100) at org.apache.lucene.util.PriorityQueue.upHeap(PriorityQueue.java:223) at org.apache.lucene.util.PriorityQueue.add(PriorityQueue.java:132)

Cause

The "CUSTOMFIELDSEARCHERKEY" database column doesn't contain any values for this custom field.

Resolution

  1. Create a new custom field in JIRA of the same custom field type

  2. Shutdown JIRA

  3. Delete the content of <<JIRA_INSTALL>>/work

    ℹ️ Run a backup from your database so we can restore it in case anything goes wrong!

  4. Run the following query in the database:

    1 SELECT * FROM customfield WHERE cfname = 'cf';

    ℹ️ Where 'cf' is the custom field name of the test custom field you've created. Copy the value from the "CUSTOMFIELDSEARCHERKEY" column (i.e: "com.atlassian.jira.plugin.system.customfieldtypes:multiselectsearcher".

  5. Identify the problematic custom field:

    1 SELECT * FROM customfield WHERE cfname = 'cfname';

    ℹ️ Where 'cfname' is the custom field name of the custom field you are having problems with.

  6. Run the following query to update the problematic custom field;

    1 UPDATE customfield set customfieldsearcherkey = 'the_value' where id=xx;

    ℹ️ Where 'the_value' is the CUSTOMFIELDSEARCHERKEY value you saved from the first query and 'xx' is the ID from the custom field retrieved in the previous query.

  7. Start JIRA

  8. Reindex JIRA

Updated on April 11, 2025

Still need help?

The Atlassian Community is here for you.