java.lang.ClassCastException: java.util.Collections$EmptyMap cannot be cast to java.lang.Comparable

Kuali JIRA | Jonathan Keller | 5 years ago
  1. 0

    It appears that, in some cases, {{Collections.emptyMap()}} is being passed as the role qualifier instead of a null. The code below is from the KNS class {{DocumentAuthorizerBase}}. This appears to be causing a problem when attempting to cache the results of permission and role checks as you can see in the stack trace below: {code:title=DocumentAuthorizerBase.java} public final boolean canInitiate(String documentTypeName, Person user) { String nameSpaceCode = KRADConstants.KUALI_RICE_SYSTEM_NAMESPACE; Map<String, String> permissionDetails = new HashMap<String, String>(); permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, documentTypeName); return getPermissionService().isAuthorizedByTemplate(user.getPrincipalId(), nameSpaceCode, KimConstants.PermissionTemplateNames.INITIATE_DOCUMENT, permissionDetails, Collections.<String, String>emptyMap()); } {code} {noformat} [junit] 2012-05-09 18:00:29,233 [main] u:/d:9212 WARN org.kuali.rice.kim.impl.role.RoleServiceImpl :: Not able to retrieve RoleTypeService from remote system for role Id: 92 [junit] java.lang.ClassCastException: java.util.Collections$EmptyMap cannot be cast to java.lang.Comparable [junit] at java.util.Collections.sort(Collections.java:121) [junit] at org.kuali.rice.core.api.cache.CacheKeyUtils.key(CacheKeyUtils.java:71) [junit] at $Proxy107.principalHasRole(Unknown Source) [junit] at org.kuali.kfs.fp.identity.CashReceiptInitiatorDerivedRoleTypeServiceImpl.hasRoleMembership(CashReceiptInitiatorDerivedRoleTypeServiceImpl.java:82) [junit] at org.kuali.kfs.fp.identity.CashReceiptInitiatorDerivedRoleTypeServiceImpl.principalMemberOfSysUsers(CashReceiptInitiatorDerivedRoleTypeServiceImpl.java:59) [junit] at org.kuali.kfs.fp.identity.CashReceiptInitiatorDerivedRoleTypeServiceImpl.hasDerivedRole(CashReceiptInitiatorDerivedRoleTypeServiceImpl.java:44) [junit] at org.kuali.rice.kim.impl.role.RoleServiceImpl.principalHasRole(RoleServiceImpl.java:1106) [junit] at org.kuali.rice.kim.impl.role.RoleServiceImpl.principalHasRole(RoleServiceImpl.java:498) [junit] at org.kuali.rice.kim.impl.permission.PermissionServiceImpl.isAuthorizedByTemplate(PermissionServiceImpl.java:172) [junit] at org.kuali.rice.kns.document.authorization.DocumentAuthorizerBase.canInitiate(DocumentAuthorizerBase.java:143) [junit] at org.kuali.rice.krad.service.impl.DocumentServiceImpl.getNewDocument(DocumentServiceImpl.java:506) [junit] at org.kuali.rice.krad.service.impl.DocumentServiceImpl.getNewDocument(DocumentServiceImpl.java:469) [junit] at org.kuali.kfs.sys.service.IsDebitTestUtils.getDocument(IsDebitTestUtils.java:110) [junit] at org.kuali.kfs.fp.document.validation.impl.CashReceiptDocumentRuleTest.testIsDebit_liability_zeroAmount(CashReceiptDocumentRuleTest.java:191) {noformat} (stripped reflection trace elements)

    Kuali JIRA | 5 years ago | Jonathan Keller
    java.lang.ClassCastException: java.util.Collections$EmptyMap cannot be cast to java.lang.Comparable
  2. 0

    It appears that, in some cases, {{Collections.emptyMap()}} is being passed as the role qualifier instead of a null. The code below is from the KNS class {{DocumentAuthorizerBase}}. This appears to be causing a problem when attempting to cache the results of permission and role checks as you can see in the stack trace below: {code:title=DocumentAuthorizerBase.java} public final boolean canInitiate(String documentTypeName, Person user) { String nameSpaceCode = KRADConstants.KUALI_RICE_SYSTEM_NAMESPACE; Map<String, String> permissionDetails = new HashMap<String, String>(); permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, documentTypeName); return getPermissionService().isAuthorizedByTemplate(user.getPrincipalId(), nameSpaceCode, KimConstants.PermissionTemplateNames.INITIATE_DOCUMENT, permissionDetails, Collections.<String, String>emptyMap()); } {code} {noformat} [junit] 2012-05-09 18:00:29,233 [main] u:/d:9212 WARN org.kuali.rice.kim.impl.role.RoleServiceImpl :: Not able to retrieve RoleTypeService from remote system for role Id: 92 [junit] java.lang.ClassCastException: java.util.Collections$EmptyMap cannot be cast to java.lang.Comparable [junit] at java.util.Collections.sort(Collections.java:121) [junit] at org.kuali.rice.core.api.cache.CacheKeyUtils.key(CacheKeyUtils.java:71) [junit] at $Proxy107.principalHasRole(Unknown Source) [junit] at org.kuali.kfs.fp.identity.CashReceiptInitiatorDerivedRoleTypeServiceImpl.hasRoleMembership(CashReceiptInitiatorDerivedRoleTypeServiceImpl.java:82) [junit] at org.kuali.kfs.fp.identity.CashReceiptInitiatorDerivedRoleTypeServiceImpl.principalMemberOfSysUsers(CashReceiptInitiatorDerivedRoleTypeServiceImpl.java:59) [junit] at org.kuali.kfs.fp.identity.CashReceiptInitiatorDerivedRoleTypeServiceImpl.hasDerivedRole(CashReceiptInitiatorDerivedRoleTypeServiceImpl.java:44) [junit] at org.kuali.rice.kim.impl.role.RoleServiceImpl.principalHasRole(RoleServiceImpl.java:1106) [junit] at org.kuali.rice.kim.impl.role.RoleServiceImpl.principalHasRole(RoleServiceImpl.java:498) [junit] at org.kuali.rice.kim.impl.permission.PermissionServiceImpl.isAuthorizedByTemplate(PermissionServiceImpl.java:172) [junit] at org.kuali.rice.kns.document.authorization.DocumentAuthorizerBase.canInitiate(DocumentAuthorizerBase.java:143) [junit] at org.kuali.rice.krad.service.impl.DocumentServiceImpl.getNewDocument(DocumentServiceImpl.java:506) [junit] at org.kuali.rice.krad.service.impl.DocumentServiceImpl.getNewDocument(DocumentServiceImpl.java:469) [junit] at org.kuali.kfs.sys.service.IsDebitTestUtils.getDocument(IsDebitTestUtils.java:110) [junit] at org.kuali.kfs.fp.document.validation.impl.CashReceiptDocumentRuleTest.testIsDebit_liability_zeroAmount(CashReceiptDocumentRuleTest.java:191) {noformat} (stripped reflection trace elements)

    Kuali JIRA | 5 years ago | Jonathan Keller
    java.lang.ClassCastException: java.util.Collections$EmptyMap cannot be cast to java.lang.Comparable
  3. 0

    Sort elements of Java ArrayList

    Stack Overflow | 3 years ago | user2996028
    java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.Comparable
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    What might cause Collections.sort(List, Comparator) to throw a ClassCastException?

    Stack Overflow | 5 years ago | pesckal
    java.lang.ClassCastException: processing.app.EmployeeManager$PrettyOkayEmpolyee cannot be cast to java.lang.Comparable
  6. 0

    cannot be cast to java.lang.Comparable

    Stack Overflow | 5 years ago | who must not be named
    java.lang.ClassCastException: FoodItems cannot be cast to java.lang.Comparable

    2 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.ClassCastException

      java.util.Collections$EmptyMap cannot be cast to java.lang.Comparable

      at java.util.Collections.sort()
    2. Java RT
      Collections.sort
      1. java.util.Collections.sort(Collections.java:121)
      1 frame
    3. org.kuali.rice
      CacheKeyUtils.key
      1. org.kuali.rice.core.api.cache.CacheKeyUtils.key(CacheKeyUtils.java:71)
      1 frame
    4. Unknown
      $Proxy107.principalHasRole
      1. $Proxy107.principalHasRole(Unknown Source)
      1 frame
    5. org.kuali.kfs
      CashReceiptInitiatorDerivedRoleTypeServiceImpl.hasDerivedRole
      1. org.kuali.kfs.fp.identity.CashReceiptInitiatorDerivedRoleTypeServiceImpl.hasRoleMembership(CashReceiptInitiatorDerivedRoleTypeServiceImpl.java:82)
      2. org.kuali.kfs.fp.identity.CashReceiptInitiatorDerivedRoleTypeServiceImpl.principalMemberOfSysUsers(CashReceiptInitiatorDerivedRoleTypeServiceImpl.java:59)
      3. org.kuali.kfs.fp.identity.CashReceiptInitiatorDerivedRoleTypeServiceImpl.hasDerivedRole(CashReceiptInitiatorDerivedRoleTypeServiceImpl.java:44)
      3 frames
    6. org.kuali.rice
      DocumentServiceImpl.getNewDocument
      1. org.kuali.rice.kim.impl.role.RoleServiceImpl.principalHasRole(RoleServiceImpl.java:1106)
      2. org.kuali.rice.kim.impl.role.RoleServiceImpl.principalHasRole(RoleServiceImpl.java:498)
      3. org.kuali.rice.kim.impl.permission.PermissionServiceImpl.isAuthorizedByTemplate(PermissionServiceImpl.java:172)
      4. org.kuali.rice.kns.document.authorization.DocumentAuthorizerBase.canInitiate(DocumentAuthorizerBase.java:143)
      5. org.kuali.rice.krad.service.impl.DocumentServiceImpl.getNewDocument(DocumentServiceImpl.java:506)
      6. org.kuali.rice.krad.service.impl.DocumentServiceImpl.getNewDocument(DocumentServiceImpl.java:469)
      6 frames
    7. org.kuali.kfs
      CashReceiptDocumentRuleTest.testIsDebit_liability_zeroAmount
      1. org.kuali.kfs.sys.service.IsDebitTestUtils.getDocument(IsDebitTestUtils.java:110)
      2. org.kuali.kfs.fp.document.validation.impl.CashReceiptDocumentRuleTest.testIsDebit_liability_zeroAmount(CashReceiptDocumentRuleTest.java:191)
      2 frames