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

Unable perform release: ClassCastException: net.sf.json.JSONNull cannot be cast to net.sf.json.JSONObject on Hudson 2.2.0

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • m2release-plugin
    • None

      Having m2release plugin installed on Hudson 2.2.0, it generates the following error when we try to perform a release (testing with dryRun)

      Apr 16, 2012 2:31:16 PM org.apache.catalina.core.StandardWrapperValve invoke
      SEVERE: Servlet.service() for servlet Stapler threw exception
      java.lang.ClassCastException: net.sf.json.JSONNull cannot be cast to net.sf.json.JSONObject
      at org.jvnet.hudson.plugins.m2release.M2ReleaseAction.doSubmit(M2ReleaseAction.java:239)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      ...

      Examining the source code, for M2ReleaseAction, it happens because there are not values in the form data for the parameter named "parameter"

      M2ReleaseAction Code:
      public void doSubmit(StaplerRequest req, StaplerResponse resp) ... {
      ...
      JSONArray a = JSONArray.fromObject(formData.get("parameter"));
      for (Object o : a) {
      JSONObject jo = (JSONObject) o;
      ...

      In order to solve this, check that we have "parameter"; or check for a possible JSONNull object:

      Possible Fix:
      JSONArray a = JSONArray.fromObject(formData.get("parameter"));
      for (Object o : a) {
      if (o instanceof JSONObject)

      { JSONObject jo = (JSONObject) o; ... }

      ...

      Note: The plugin is installed on Hudson with the workaround described in #JENKINS-12991

          [JENKINS-13465] Unable perform release: ClassCastException: net.sf.json.JSONNull cannot be cast to net.sf.json.JSONObject on Hudson 2.2.0

          I have the same issue. Any expected release date for the pull request above?

          Bruno Medeiros added a comment - I have the same issue. Any expected release date for the pull request above?

          Tan Nguyen added a comment -

          Well, you can vote for it. During the transition you can apply the patch above yourself or take the patched hpi and replace it in your jenkins/hudson installation. hth

          Tan Nguyen added a comment - Well, you can vote for it. During the transition you can apply the patch above yourself or take the patched hpi and replace it in your jenkins/hudson installation. hth

          Toni Menzel added a comment - - edited

          We are also facing this on Jenkins and maven-release-plugin 2.2.2.
          Now a tricky question: we are hitting this problem for the first time starting today.
          Whats the evidence behind this ? I mean the jenkins plugin WAS working. But something changed. What is something here ? Is it Jenkins.

          Any release date scheduled ?

          Toni Menzel added a comment - - edited We are also facing this on Jenkins and maven-release-plugin 2.2.2. Now a tricky question: we are hitting this problem for the first time starting today. Whats the evidence behind this ? I mean the jenkins plugin WAS working. But something changed. What is something here ? Is it Jenkins. Any release date scheduled ?

          Scott Oster added a comment -

          I have the same problem with Jenkins 1.506 and 0.9.1 of maven release plugin. I cannot perform a release.

          Scott Oster added a comment - I have the same problem with Jenkins 1.506 and 0.9.1 of maven release plugin. I cannot perform a release.

          Bertrand Gillis added a comment - - edited

          I have the same problem and 2.2.1 of maven release plugin. I cannot perform a release anymore. So I've reverted back to jenkins 1.504 (last stable version for us).

          Bertrand Gillis added a comment - - edited I have the same problem and 2.2.1 of maven release plugin. I cannot perform a release anymore. So I've reverted back to jenkins 1.504 (last stable version for us).

          I tested Gabriel's pull request and can confirm that it fixes the problem for me. Would be nice if we could have a new plugin release.

          Richard Mortimer added a comment - I tested Gabriel's pull request and can confirm that it fixes the problem for me. Would be nice if we could have a new plugin release.

          It seems like the bug has been introduced the fix for JENKINS-10127. As a simple workaround you may configure an arbitrary parameter for your build.

          Martin Centner added a comment - It seems like the bug has been introduced the fix for JENKINS-10127 . As a simple workaround you may configure an arbitrary parameter for your build.

          Code changed in jenkins
          User: glandais
          Path:
          src/main/java/org/jvnet/hudson/plugins/m2release/M2ReleaseAction.java
          http://jenkins-ci.org/commit/m2release-plugin/3ac6000a844d0a1247024306b82cd123b0328c34
          Log:
          Update M2ReleaseAction.java

          JENKINS-13465

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: glandais Path: src/main/java/org/jvnet/hudson/plugins/m2release/M2ReleaseAction.java http://jenkins-ci.org/commit/m2release-plugin/3ac6000a844d0a1247024306b82cd123b0328c34 Log: Update M2ReleaseAction.java JENKINS-13465

          Code changed in jenkins
          User: jtnord
          Path:
          src/main/java/org/jvnet/hudson/plugins/m2release/M2ReleaseAction.java
          http://jenkins-ci.org/commit/m2release-plugin/2e22caafe9cb4c52e98043ab913aa902d09a2ec7
          Log:
          Merge pull request #9 from glandais/master

          Proposed fix for JENKINS-13465

          Compare: https://github.com/jenkinsci/m2release-plugin/compare/3f825e999357...2e22caafe9cb

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: jtnord Path: src/main/java/org/jvnet/hudson/plugins/m2release/M2ReleaseAction.java http://jenkins-ci.org/commit/m2release-plugin/2e22caafe9cb4c52e98043ab913aa902d09a2ec7 Log: Merge pull request #9 from glandais/master Proposed fix for JENKINS-13465 Compare: https://github.com/jenkinsci/m2release-plugin/compare/3f825e999357...2e22caafe9cb

          I'm using the latest snapshot and the fix is working, thanks!

          Patrick McKeown added a comment - I'm using the latest snapshot and the fix is working, thanks!

            Unassigned Unassigned
            bantunes Bruno Antunes
            Votes:
            55 Vote for this issue
            Watchers:
            55 Start watching this issue

              Created:
              Updated:
              Resolved: