ClassCastException when indexing issues, due to misconfigured Script Runner scripted field
This problem is related to a third party plugin, and therefore not supported by Atlassian. See Atlassian Supported Plugins for more information.
症状
When performing a reindex, it does not complete, showing a ClassCastException error:
Individual operations updating some issues will also fail with the same exception. The following appears in the atlassian-jira.log
:
2014-12-23 17:39:50,209 http-bio-8080-exec-21 ERROR admin 1059x1112x1 141f26d 0:0:0:0:0:0:0:1 /rest/api/2/issue/TEST-2/comment [event.listeners.search.IssueIndexListener] Error re-indexing changes for issue 'TEST-2'
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double
at com.atlassian.jira.issue.index.indexers.impl.NumberCustomFieldIndexer.addDocumentFields(NumberCustomFieldIndexer.java:44)
at com.atlassian.jira.issue.index.indexers.impl.NumberCustomFieldIndexer.addDocumentFieldsSearchable(NumberCustomFieldIndexer.java:31)
at com.atlassian.jira.issue.index.indexers.impl.AbstractCustomFieldIndexer.addIndex(AbstractCustomFieldIndexer.java:46)
at com.atlassian.jira.issue.index.IssueDocument.getDocument(IssueDocument.java:41)
...
原因
This error can be caused by a scripted field set up with the Groovy Script Runner add-on for JIRA, which has the "Searcher" configured to be a Number, while the value being returned from the script is actually a text string not containing only a number.
ソリューション
- Load the "Script Fields" page in JIRA Administration
- Go through the fields, and look for any with a Number searcher
Determine if the code can possibly return a string containing anything other than a number
- Either change the searcher to be text, or change the code to return a number, depending on the desired outcome of the field
Note that the actual content of these scripts is outside the scope of Atlassian Support. For assistance with this please visit Atlassian Answers to contact the plugin vendor and/or community for support.