Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-6797

Add @DataBoundConstructor

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • groovy-plugin
    • None
    • All

      DescriptorImpl.newInstance() is deprecated since a while and @DataBoundConstructor should be used instead.

      Builders not having a @DataBoundConstructor can't be used within Extensions (e.g. BuildWrappers) a using @DataBoundConstructor itself.
      Please add a @DataBoundConstructor to

      • hudson.plugins.groovy.Groovy
        and
      • hudson.plugins.groovy.ScriptSource

      Caused by: java.lang.IllegalArgumentException: Failed to instantiate class hudson.plugins.groovy.Groovy from {"groovyName":"(Default)","kind":"hudson.plugins.groovy.Groovy$DescriptorImpl","parameters":"","properties":"","scriptParameters":"","scriptSource":

      {"scriptFile":"dummy.groovy","value":"0"}

      ,"stapler-class":"hudson.plugins.groovy.Groovy"}
      at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:352)
      at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:552)
      at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:587)
      at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:344)
      ... 40 more
      Caused by: org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class hudson.plugins.groovy.Groovy
      at org.kohsuke.stapler.RequestImpl.loadConstructorParamNames(RequestImpl.java:461)
      at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:331)

      Caused by: java.lang.IllegalArgumentException: Failed to convert the scriptSource parameter of the constructor public hudson.plugins.groovy.SystemGroovy(hudson.plugins.groovy.ScriptSource,java.lang.String,java.lang.String)
      at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:346)
      ... 43 more
      Caused by: java.lang.IllegalArgumentException: Failed to instantiate interface hudson.plugins.groovy.ScriptSource from

      {"command":"println(\"hello\")","value":"1"}

      at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:352)
      at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:552)
      at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:344)
      ... 43 more
      Caused by: org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of interface hudson.plugins.groovy.ScriptSource
      at org.kohsuke.stapler.RequestImpl.loadConstructorParamNames(RequestImpl.java:461)
      at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:331)

      The same already had to be done for 'hudson.tasks.Shell' in the core - see http://hudson.361315.n4.nabble.com/DataBoundConstructor-td2244199.html

            lvotypkova Lucie Votypkova
            domi Dominik Bartholdi
            Votes:
            7 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: