Editing a Custom Field throws "cannot be cast to java.lang.String"
症状
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)
原因
The "CUSTOMFIELDSEARCHERKEY" database column doesn't contain any values for this custom field.
ソリューション
- Create a new custom field in JIRA of the same custom field type
- Jira をシャットダウンします。
- Delete the content of <<JIRA_INSTALL>>/work
Run a backup from your database so we can restore it in case anything goes wrong! データベースで次のクエリを実行します。
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".
Identify the problematic custom field:
SELECT * FROM customfield WHERE cfname = 'cfname';
Where 'cfname' is the custom field name of the custom field you are having problems with.
Run the following query to update the problematic custom field;
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.
- Jira を起動します。
- Reindex JIRA