java.lang.ClassCastException: org.jenkinsci.plugins.workflow.steps.CoreStep.delegate expects interface jenkins.tasks.SimpleBuildStep but received class java.lang.String

Jenkins JIRA | James Nord | 1 year ago
  1. 0

    Snippet generator generates this for input step with choice parameters: {code} input message: '', parameters: [[$class: 'ChoiceParameterDefinition', choices: ['option1', 'option2'], description: '', name: 'My param']] {code} That code tries to use the {{@DataboundConstructor}} of {{ChoiceParameterDefinition}} which does not match with the required signature, thus this warning stack trace is shown on snippet generation time: {code} May 04, 2016 10:25:46 AM org.jenkinsci.plugins.structs.describable.DescribableModel uninstantiate WARNING: Cannot create control version of class hudson.model.ChoiceParameterDefinition using {choices=[option1, option2], description=, name=select} java.lang.ClassCastException: hudson.model.ChoiceParameterDefinition.choices expects class java.lang.String but received class java.util.Arrays$ArrayList at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:317) at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:248) at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:192) at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate(DescribableModel.java:440) at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate_(DescribableModel.java:466) at org.jenkinsci.plugins.structs.describable.DescribableParameter.uncoerce(DescribableParameter.java:164) at org.jenkinsci.plugins.structs.describable.DescribableParameter.uncoerce(DescribableParameter.java:158) at org.jenkinsci.plugins.structs.describable.DescribableParameter.inspect(DescribableParameter.java:112) at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate(DescribableModel.java:426) at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate_(DescribableModel.java:466) at org.jenkinsci.plugins.workflow.steps.StepDescriptor.defineArguments(StepDescriptor.java:114) at org.jenkinsci.plugins.workflow.cps.Snippetizer.object2Groovy(Snippetizer.java:68) at org.jenkinsci.plugins.workflow.cps.Snippetizer.doGenerateSnippet(Snippetizer.java:218) {code} The generated snippet does not work later on runtime, throwing the same exception.

    Jenkins JIRA | 7 months ago | Antonio Muñiz
    java.lang.ClassCastException: hudson.model.ChoiceParameterDefinition.choices expects class java.lang.String but received class java.util.Arrays$ArrayList
  2. Speed up your debug routine!

    Automated exception search integrated into your IDE

  3. 0

    Using Snippet Generator for creating an input statement with choice parameter you get next sentence: {code} input message: 'Environment to Deploy', parameters: [[$class: 'ChoiceParameterDefinition', choices: ['local','pre'], description: '', name: 'environment']] {code} But then when you execute the script you get next exception: {code} java.lang.ClassCastException: hudson.model.ChoiceParameterDefinition.choices expects class java.lang.String but received class java.util.ArrayList at org.jenkinsci.plugins.workflow.structs.DescribableHelper.coerce(DescribableHelper.java:590) at org.jenkinsci.plugins.workflow.structs.DescribableHelper.buildArguments(DescribableHelper.java:524) at org.jenkinsci.plugins.workflow.structs.DescribableHelper.instantiate(DescribableHelper.java:96) at org.jenkinsci.plugins.workflow.structs.DescribableHelper.coerce(DescribableHelper.java:576) at org.jenkinsci.plugins.workflow.structs.DescribableHelper.mapList(DescribableHelper.java:603) at org.jenkinsci.plugins.workflow.structs.DescribableHelper.coerce(DescribableHelper.java:588) at org.jenkinsci.plugins.workflow.structs.DescribableHelper.buildArguments(DescribableHelper.java:524) at org.jenkinsci.plugins.workflow.structs.DescribableHelper.injectSetters(DescribableHelper.java:663) at org.jenkinsci.plugins.workflow.structs.DescribableHelper.instantiate(DescribableHelper.java:98) at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:103) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:133) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:113) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:15) at WorkflowScript.run(WorkflowScript:1) at ___cps.transform___(Native Method) at com.cloudbees.groovy.cps.impl.Cont {code}

    Jenkins JIRA | 9 months ago | Alex Soto
    java.lang.ClassCastException: hudson.model.ChoiceParameterDefinition.choices expects class java.lang.String but received class java.util.ArrayList
  4. 0

    Using Snippet Generator for creating an input statement with choice parameter you get next sentence: {code} input message: 'Environment to Deploy', parameters: [[$class: 'ChoiceParameterDefinition', choices: ['local','pre'], description: '', name: 'environment']] {code} But then when you execute the script you get next exception: {code} java.lang.ClassCastException: hudson.model.ChoiceParameterDefinition.choices expects class java.lang.String but received class java.util.ArrayList at org.jenkinsci.plugins.workflow.structs.DescribableHelper.coerce(DescribableHelper.java:590) at org.jenkinsci.plugins.workflow.structs.DescribableHelper.buildArguments(DescribableHelper.java:524) at org.jenkinsci.plugins.workflow.structs.DescribableHelper.instantiate(DescribableHelper.java:96) at org.jenkinsci.plugins.workflow.structs.DescribableHelper.coerce(DescribableHelper.java:576) at org.jenkinsci.plugins.workflow.structs.DescribableHelper.mapList(DescribableHelper.java:603) at org.jenkinsci.plugins.workflow.structs.DescribableHelper.coerce(DescribableHelper.java:588) at org.jenkinsci.plugins.workflow.structs.DescribableHelper.buildArguments(DescribableHelper.java:524) at org.jenkinsci.plugins.workflow.structs.DescribableHelper.injectSetters(DescribableHelper.java:663) at org.jenkinsci.plugins.workflow.structs.DescribableHelper.instantiate(DescribableHelper.java:98) at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:103) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:133) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:113) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:15) at WorkflowScript.run(WorkflowScript:1) at ___cps.transform___(Native Method) at com.cloudbees.groovy.cps.impl.Cont {code}

    Jenkins JIRA | 9 months ago | Alex Soto
    java.lang.ClassCastException: hudson.model.ChoiceParameterDefinition.choices expects class java.lang.String but received class java.util.ArrayList

    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

      org.jenkinsci.plugins.workflow.steps.CoreStep.delegate expects interface jenkins.tasks.SimpleBuildStep but received class java.lang.String

      at org.jenkinsci.plugins.workflow.structs.DescribableHelper.coerce()
    2. org.jenkinsci.plugins
      DSL.invokeMethod
      1. org.jenkinsci.plugins.workflow.structs.DescribableHelper.coerce(DescribableHelper.java:250)
      2. org.jenkinsci.plugins.workflow.structs.DescribableHelper.buildArguments(DescribableHelper.java:186)
      3. org.jenkinsci.plugins.workflow.structs.DescribableHelper.instantiate(DescribableHelper.java:91)
      4. org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:103)
      5. org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:133)
      5 frames