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

Transient InvalidClassException: org.jenkinsci.plugins.envinject.EnvInjectListener$2

    Details

    • Similar Issues:

      Description

      https://partnerdemo.ci.cloudbees.com/job/Cloud-Foundry/job/spring-maven/1/ failed with:

      [EnvInject] - Loading node environment variables.
      [EnvInject] - [ERROR] - SEVERE ERROR occurs: java.io.InvalidClassException: org.jenkinsci.plugins.envinject.EnvInjectListener$2; org.jenkinsci.plugins.envinject.EnvInjectListener$2; class invalid for deserialization
      

      which corrected itself after a restart. The 1.83 plugin was in use (at least after the restart—not sure about before); the inner class seems to be this:

      return new Environment() {
          @Override
          public void buildEnvVars(Map<String, String> env) {
              envInjectEnvVarsService.resolveVars(mergedVariables, mergedVariables);
              env.putAll(mergedVariables);
          }
      };
      

      Environment is not meant to be serializable AFAICT so I am not sure why this was producing a serialization-related error message. But if this class does in fact get sent over the wire, using an anonymous inner class is dangerous. Refactor into a named static member class instead. Or perhaps some other inner class was supposed to be serializable, and got confused with this one due to the generic name $2, in which case there would be a similar fix.

      The job was a Maven moduleset, with no configuration from the plugin.

      By the way various copies of

      new Environment() {}
      

      could be factored into a single constant; or better yet, use the factory method in Environment with an empty EnvVars.

        Attachments

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              gbois Gregory Boissinot
              Reporter:
              jglick Jesse Glick
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: