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

Still need help?

The Atlassian Community is here for you.

Ask the community

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:

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
    (info) Run a backup from your database so we can restore it in case anything goes wrong!
  4. Run the following query in the database:

    SELECT * FROM customfield WHERE cfname = 'cf';

    (info) 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:

    SELECT * FROM customfield WHERE cfname = 'cfname';

    (info) 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;

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

    (info) 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

Last modified on Oct 5, 2016

Was this helpful?

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