java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String

Atlassian JIRA | Renan Battaglin | 6 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    The following exception is reported when Bamboo tries to cast to String a list of values: {code} SEVERE: Servlet.service() for servlet default threw exception java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String at com.atlassian.bamboo.utils.ConfigUtils.copyMapToConfig(ConfigUtils.java:30) at com.atlassian.bamboo.fieldvalue.BuildDefinitionConverter.fromObject(BuildDefinitionConverter.java:135) at com.atlassian.bamboo.ww2.interceptors.BuildConfigurationEditInterceptor.intercept(BuildConfigurationEditInterceptor.java:41) at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190) at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31) at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190) at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:116) {code} {code} public class ConfigUtils { private static final Logger log = Logger.getLogger(ConfigUtils.class); public static void copyMapToConfig(Map map, Configuration config) { for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) { Map.Entry entry = (Map.Entry) iterator.next(); String key = (String) entry.getKey(); String value = (String) entry.getValue(); config.setProperty(key, value); } } {code} Printing the value that caused the problem (Key and Value): {code} 2010-10-29 09:52:26,106 DEBUG [BAM::Bamboo Server Agent::Agent:pool-4-thread-1] [ConfigUtils] custom.sysbliss.success.command 2010-10-29 09:52:26,106 DEBUG [BAM::Bamboo Server Agent::Agent:pool-4-thread-1] [ConfigUtils] [, ] {code} Equivalent DB XML code (BuildDefinition table) {code} <sysbliss> <pre> <command/> <command> <run><location>A</location></run> </command> </pre> <failed> <command/> <command/> </failed> <success> <command/> <command/> </success> <post> <command> <run><location>A</location></run> </command> </post> </sysbliss> {code} The problem above is from the *Pre-Post Build Command Runner* plugin. However it also happened to the *Clearcase* plugin (Key and Value): {code} custom.repository.cc.dynamicView [true, true] {code}

    Atlassian JIRA | 6 years ago | Renan Battaglin
    java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String
  2. 0

    The following exception is reported when Bamboo tries to cast to String a list of values: {code} SEVERE: Servlet.service() for servlet default threw exception java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String at com.atlassian.bamboo.utils.ConfigUtils.copyMapToConfig(ConfigUtils.java:30) at com.atlassian.bamboo.fieldvalue.BuildDefinitionConverter.fromObject(BuildDefinitionConverter.java:135) at com.atlassian.bamboo.ww2.interceptors.BuildConfigurationEditInterceptor.intercept(BuildConfigurationEditInterceptor.java:41) at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190) at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31) at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190) at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:116) {code} {code} public class ConfigUtils { private static final Logger log = Logger.getLogger(ConfigUtils.class); public static void copyMapToConfig(Map map, Configuration config) { for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) { Map.Entry entry = (Map.Entry) iterator.next(); String key = (String) entry.getKey(); String value = (String) entry.getValue(); config.setProperty(key, value); } } {code} Printing the value that caused the problem (Key and Value): {code} 2010-10-29 09:52:26,106 DEBUG [BAM::Bamboo Server Agent::Agent:pool-4-thread-1] [ConfigUtils] custom.sysbliss.success.command 2010-10-29 09:52:26,106 DEBUG [BAM::Bamboo Server Agent::Agent:pool-4-thread-1] [ConfigUtils] [, ] {code} Equivalent DB XML code (BuildDefinition table) {code} <sysbliss> <pre> <command/> <command> <run><location>A</location></run> </command> </pre> <failed> <command/> <command/> </failed> <success> <command/> <command/> </success> <post> <command> <run><location>A</location></run> </command> </post> </sysbliss> {code} The problem above is from the *Pre-Post Build Command Runner* plugin. However it also happened to the *Clearcase* plugin (Key and Value): {code} custom.repository.cc.dynamicView [true, true] {code}

    Atlassian JIRA | 6 years ago | Renan Battaglin
    java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String

    Root Cause Analysis

    1. java.lang.ClassCastException

      java.util.ArrayList cannot be cast to java.lang.String

      at com.atlassian.bamboo.utils.ConfigUtils.copyMapToConfig()
    2. com.atlassian.bamboo
      BuildConfigurationEditInterceptor.intercept
      1. com.atlassian.bamboo.utils.ConfigUtils.copyMapToConfig(ConfigUtils.java:30)
      2. com.atlassian.bamboo.fieldvalue.BuildDefinitionConverter.fromObject(BuildDefinitionConverter.java:135)
      3. com.atlassian.bamboo.ww2.interceptors.BuildConfigurationEditInterceptor.intercept(BuildConfigurationEditInterceptor.java:41)
      3 frames
    3. XWork Tiger Extensions
      DefaultActionInvocation.invoke
      1. com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
      1 frame
    4. com.opensymphony.xwork
      AroundInterceptor.intercept
      1. com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
      1 frame
    5. XWork Tiger Extensions
      DefaultActionProxy.execute
      1. com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
      2. com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:116)
      2 frames