java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.String;

Apereo Issues | Sander Bos | 8 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    I have configured the Cas20ProxyReceivingTicketValidationFilter with the parameter <init-param> <param-name>allowedProxyChains</param-name> <param-value>https://fina138:8443/cas/proxyCallback</param-value> </init-param> (although actually the value does not matter at all) The error I get is java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.String; at org.jasig.cas.client.validation.ProxyList.contains(ProxyList.java:34) at org.jasig.cas.client.validation.Cas20ProxyTicketValidator.customParseResponse(Cas20ProxyTicketValidator.java:47) at org.jasig.cas.client.validation.Cas20ServiceTicketValidator.parseResponseFromServer(Cas20ServiceTicketValidator.java:94) at org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator.validate(AbstractUrlBasedTicketValidator.java:188) at org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:132) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) The reason is Cas20ProxyReceivingTicketValidationFilter.java protected final List constructListOfProxies(final String proxies) { if (CommonUtils.isBlank(proxies)) { return new ArrayList(); } final String[] splitProxies = proxies.split("\n"); final List items = Arrays.asList(splitProxies); final ProxyListEditor editor = new ProxyListEditor(); editor.setValue(items); return (List) editor.getValue(); } The string is split on newlines but not any further. Then editor.setValue and editor.getValue is called which do essentially nothing, so you end up with a list of strings instead of a list of string arrays (one string array is one proxy chain, and you want to create a list of string arrays). Note on fix: I guess a fix is to not do any string splits here, and instead call editor.setAsText(proxies). But that is not enough, because then in ProxyListEditor you have to do setValue(proxyChains); instead of setValue(new ProxyList(proxyChains)); at the minimum.

    Apereo Issues | 8 years ago | Sander Bos
    java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.String;
  2. 0

    I have configured the Cas20ProxyReceivingTicketValidationFilter with the parameter <init-param> <param-name>allowedProxyChains</param-name> <param-value>https://fina138:8443/cas/proxyCallback</param-value> </init-param> (although actually the value does not matter at all) The error I get is java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.String; at org.jasig.cas.client.validation.ProxyList.contains(ProxyList.java:34) at org.jasig.cas.client.validation.Cas20ProxyTicketValidator.customParseResponse(Cas20ProxyTicketValidator.java:47) at org.jasig.cas.client.validation.Cas20ServiceTicketValidator.parseResponseFromServer(Cas20ServiceTicketValidator.java:94) at org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator.validate(AbstractUrlBasedTicketValidator.java:188) at org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:132) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) The reason is Cas20ProxyReceivingTicketValidationFilter.java protected final List constructListOfProxies(final String proxies) { if (CommonUtils.isBlank(proxies)) { return new ArrayList(); } final String[] splitProxies = proxies.split("\n"); final List items = Arrays.asList(splitProxies); final ProxyListEditor editor = new ProxyListEditor(); editor.setValue(items); return (List) editor.getValue(); } The string is split on newlines but not any further. Then editor.setValue and editor.getValue is called which do essentially nothing, so you end up with a list of strings instead of a list of string arrays (one string array is one proxy chain, and you want to create a list of string arrays). Note on fix: I guess a fix is to not do any string splits here, and instead call editor.setAsText(proxies). But that is not enough, because then in ProxyListEditor you have to do setValue(proxyChains); instead of setValue(new ProxyList(proxyChains)); at the minimum.

    Apereo Issues | 8 years ago | Sander Bos
    java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.String;

    Root Cause Analysis

    1. java.lang.ClassCastException

      java.lang.String cannot be cast to [Ljava.lang.String;

      at org.jasig.cas.client.validation.ProxyList.contains()
    2. Jasig CAS Client for Java - Core
      AbstractTicketValidationFilter.doFilter
      1. org.jasig.cas.client.validation.ProxyList.contains(ProxyList.java:34)
      2. org.jasig.cas.client.validation.Cas20ProxyTicketValidator.customParseResponse(Cas20ProxyTicketValidator.java:47)
      3. org.jasig.cas.client.validation.Cas20ServiceTicketValidator.parseResponseFromServer(Cas20ServiceTicketValidator.java:94)
      4. org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator.validate(AbstractUrlBasedTicketValidator.java:188)
      5. org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:132)
      5 frames
    3. Glassfish Core
      ApplicationFilterChain.internalDoFilter
      1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      1 frame