java.lang.ClassCastException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • If a multi user custom field is added to JIRA, and the custom field is added to the Assignable User permission, the Assign Issue operation breaks, when trying to gather the list of assignable Users. This is basically because our MultiUserCF is not specific enough and relies to much on the AbstractMultiCFType. The MultiUserCFType needs to override the getValueFromIssue(CustomField field, Issue issue) method to return a *Set* rather than a *List*. Or, we could make the UserCF a little more robust and make the following method able to handle more than just a Set: {code} public Set getUsers(PermissionContext ctx, String customFieldId) { if (ctx.getIssue() == null) { throw new IllegalArgumentException("PermissionContext has no issue"); } Issue issue = ctx.getIssue(); FieldManager fieldManager = ComponentManager.getInstance().getFieldManager(); CustomField field = fieldManager.getCustomField(customFieldId); CustomFieldType type = field.getCustomFieldType(); Object obj = type.getValueFromIssue(field, issue); Set users = new HashSet(1); if (obj != null) { if (obj instanceof Set) { users = (Set) obj; } else { users.add(obj); } } return users; } {code} Currently it can't, and the following exception is the result (a little further down the track, after the UserCF has added the wrong thing to the set of users): {noformat} java.lang.ClassCastException: java.util.ArrayList cannot be cast to com.opensymphony.user.User at com.atlassian.core.user.BestNameComparator.compare(BestNameComparator.java:26) at java.util.Arrays.mergeSort(Arrays.java:1270) at java.util.Arrays.sort(Arrays.java:1210) at java.util.Collections.sort(Collections.java:159) at com.atlassian.jira.issue.fields.AssigneeSystemField.makeAssigneeOptionsList(AssigneeSystemField.java:416) at com.atlassian.jira.issue.fields.AssigneeSystemField.getAssigneeOptionsList(AssigneeSystemField.java:348) at com.atlassian.jira.issue.fields.AssigneeSystemField.getEditHtml(AssigneeSystemField.java:87) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:589) at webwork.util.InjectionUtils$DefaultInjectionImpl.invoke(InjectionUtils.java:61) at webwork.util.InjectionUtils.invoke(InjectionUtils.java:52) at webwork.util.ValueStack.findValue(ValueStack.java:426) {noformat}
    via by Andreas Knecht,
  • If a multi user custom field is added to JIRA, and the custom field is added to the Assignable User permission, the Assign Issue operation breaks, when trying to gather the list of assignable Users. This is basically because our MultiUserCF is not specific enough and relies to much on the AbstractMultiCFType. The MultiUserCFType needs to override the getValueFromIssue(CustomField field, Issue issue) method to return a *Set* rather than a *List*. Or, we could make the UserCF a little more robust and make the following method able to handle more than just a Set: {code} public Set getUsers(PermissionContext ctx, String customFieldId) { if (ctx.getIssue() == null) { throw new IllegalArgumentException("PermissionContext has no issue"); } Issue issue = ctx.getIssue(); FieldManager fieldManager = ComponentManager.getInstance().getFieldManager(); CustomField field = fieldManager.getCustomField(customFieldId); CustomFieldType type = field.getCustomFieldType(); Object obj = type.getValueFromIssue(field, issue); Set users = new HashSet(1); if (obj != null) { if (obj instanceof Set) { users = (Set) obj; } else { users.add(obj); } } return users; } {code} Currently it can't, and the following exception is the result (a little further down the track, after the UserCF has added the wrong thing to the set of users): {noformat} java.lang.ClassCastException: java.util.ArrayList cannot be cast to com.opensymphony.user.User at com.atlassian.core.user.BestNameComparator.compare(BestNameComparator.java:26) at java.util.Arrays.mergeSort(Arrays.java:1270) at java.util.Arrays.sort(Arrays.java:1210) at java.util.Collections.sort(Collections.java:159) at com.atlassian.jira.issue.fields.AssigneeSystemField.makeAssigneeOptionsList(AssigneeSystemField.java:416) at com.atlassian.jira.issue.fields.AssigneeSystemField.getAssigneeOptionsList(AssigneeSystemField.java:348) at com.atlassian.jira.issue.fields.AssigneeSystemField.getEditHtml(AssigneeSystemField.java:87) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:589) at webwork.util.InjectionUtils$DefaultInjectionImpl.invoke(InjectionUtils.java:61) at webwork.util.InjectionUtils.invoke(InjectionUtils.java:52) at webwork.util.ValueStack.findValue(ValueStack.java:426) {noformat}
    via by Andreas Knecht,
    • java.lang.ClassCastException: java.util.ArrayList cannot be cast to com.opensymphony.user.User at com.atlassian.core.user.BestNameComparator.compare(BestNameComparator.java:26) at java.util.Arrays.mergeSort(Arrays.java:1270) at java.util.Arrays.sort(Arrays.java:1210) at java.util.Collections.sort(Collections.java:159) at com.atlassian.jira.issue.fields.AssigneeSystemField.makeAssigneeOptionsList(AssigneeSystemField.java:416) at com.atlassian.jira.issue.fields.AssigneeSystemField.getAssigneeOptionsList(AssigneeSystemField.java:348) at com.atlassian.jira.issue.fields.AssigneeSystemField.getEditHtml(AssigneeSystemField.java:87) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:589) at webwork.util.InjectionUtils$DefaultInjectionImpl.invoke(InjectionUtils.java:61) at webwork.util.InjectionUtils.invoke(InjectionUtils.java:52) at webwork.util.ValueStack.findValue(ValueStack.java:426)
    No Bugmate found.