Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Getting java.lang.ClassCastException: java.util.HashMap cannot be cast in jira5

Ramesh Udari1 November 4, 2012

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

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Florin Manaila
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 4, 2012

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.

TAGS
AUG Leaders

Atlassian Community Events