We are upgrading jira form 4.3 to 5.0.2 and while migrating existing plugin we are getting ClassCastException exception when we use the below code.
CustomField customField = customFieldManager.getCustomFieldObjectByName(customfieldName); CustomFieldParams cfParams = (CustomFieldParams)customField.getValue(mutableIssue); Object value1 = cfParams.getFirstValueForKey(null); Object value2 = cfParams.getFirstValueForKey("1"); strValue1 = value1.toString(); if(value2 != null) { strValue2 = value2.toString(); }
Exception:2012-11-05 17:09:01,961 http-8080-Processor19 INFO ramesh.udari 1029x133x1 y6s6ee 172.17.6.206 /secure/ConfigureReport.jspa [helpdesk.plugin.manager.DatabaseConnection] .......................Connection Successful FOr TAT!
java.lang.ClassCastException: java.util.HashMap cannot be cast to com.atlassian.jira.issue.customfields.view.CustomFieldParams
Community moderators have prevented the ability to post new answers.
I'm assuming this is about a cascading select custom field. Jira 5 has changed its internal representation from CustomFieldParamsImpl to a HashMap (they have similar methods). You will find the values in the new HashMap implementation similar to what it used to be in CustomFieldParamsImpl.
map.get(CascadingSelectCFType.PARENT_KEY) // parent key is null
map.get(CascadingSelectCFType.CHILD_KEY) // child key is "1"
So line 3 in your code should actually cast to a HashMap and use it as I said above.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.