4
FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
java.lang.NoClassDefFoundError: Could not initialize class hudson.util.ProcessTree$UnixReflection
at hudson.util.ProcessTree$UnixProcess.kill(ProcessTree.java:647)
at hudson.util.ProcessTree$UnixProcess.killRecursively(ProcessTree.java:668)
at hudson.util.ProcessTree$UnixProcess.killRecursively(ProcessTree.java:667)
at hudson.util.ProcessTree$Unix.killAll(ProcessTree.java:589)
at hudson.Launcher$LocalLauncher.kill(Launcher.java:949)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:502)
at hudson.model.Run.execute(Run.java:1737)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:421)

Jenkins ver. 2.73.3 MacOSx

Doing an iOS build and upload to hockeyapp. The .ipa is created successfully, error seems to happen afterwards, seems like on the hockeyapp upload. I have an android project that works and uploads to hockeyapp successfully though.

Started getting this today after updating Jenkins and plugins. Was working before.

Any ideas?

Alan Bateman
  • 5,283
  • 1
  • 20
  • 25
CodeSmith
  • 1,621
  • 1
  • 13
  • 31
  • Looks like it has been hacking into a private method in the implementation but the implementation has been refactored in JDK 9 so that private method no longer exists. Best to check the Jenkins issue tracker, maybe it has been logged or fixed already. – Alan Bateman Nov 17 '17 at 14:51

3 Answers3

3

happened to me when running an Android build (Jenkins build 2.86, I just downgraded from 2.87 or something slighlty newer, because of other fails)

Build step 'Invoke Gradle script' changed build result to SUCCESS
FATAL: Could not initialize class 
hudson.util.ProcessTree$UnixReflection
java.lang.NoClassDefFoundError: Could not initialize class 
hudson.util.ProcessTree$UnixReflection
at hudson.util.ProcessTree$UnixProcess.kill(ProcessTree.java:647)
at hudson.util.ProcessTree$UnixProcess.killRecursively(ProcessTree.java:668)
at hudson.util.ProcessTree$Unix.killAll(ProcessTree.java:589)
at hudson.Launcher$LocalLauncher.kill(Launcher.java:949)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:510)
at hudson.model.Run.execute(Run.java:1724)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:421)
Finished: FAILURE

first SUCCESS then FAILURE, hmm weeeird

I remembered that recently I have installed java 9 for experimenting, but still having java 8 set to usl/libexec/java_home, in my .zshrc like:

export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_152`

but that did not help at all, so I said goodbye to Java 9 with

sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk

then went to Manage Jenkins -> Configure System -> Environment variables and added

/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home

as JAVA_HOME

after Jenkins restart my builds run like a charm

Piotr Z
  • 864
  • 11
  • 11
  • Ok, yes looks like Java 9 was installed and that seems suspicious. Working on removing it and testing again. – CodeSmith Nov 17 '17 at 23:22
  • Finally got it working again, I had to uninstall java 9 but also update java 8 to the latest version. Looks like I wanted to fix another issue by updating java and tried java 9 but ran into this problem after updating my jenkins plugins. At any rate, using the latest java 8 (1.8.0_151 currently) seems to have resolved the problem. – CodeSmith Nov 21 '17 at 18:22
  • @CodeSmith How to un-install and install java version 8? Need urgent help. – pkc456 Jun 07 '18 at 07:16
  • @pkc456 your question lacks basic information, such as which operating system you are on... if you are on OSX you can try doing it similarly as in my answer above – Piotr Z Jun 07 '18 at 13:16
  • 10.13.3 Mac Operating system – pkc456 Jun 08 '18 at 08:26
  • https://stackoverflow.com/questions/19039752/removing-java-8-jdk-from-mac – Piotr Z Jun 08 '18 at 09:52
0

While staying with Java 8, wiping the current workspace on Jenkins got rid of the error for me. Got the error after updating gradle and the sonarqube plugin version.

Stefan L
  • 1,529
  • 13
  • 20
0

we've been seeing this intermittently on an old Jenkins server and I think we've tracked it down. It happens when there are background processes left after a job runs and can be easily reproduced with this job script:

sleep 30 &
exit 0

The error Could not initialize class hudson.util.ProcessTree$UnixReflection comes from this static initializer:

        static {
            try {
                Class<?> clazz = Class.forName("java.lang.UNIXProcess");
                PID_FIELD = clazz.getDeclaredField("pid");
                PID_FIELD.setAccessible(true);

                if (isPreJava8()) {
                    DESTROY_PROCESS = clazz.getDeclaredMethod("destroyProcess",int.class);
                } else {
                    DESTROY_PROCESS = clazz.getDeclaredMethod("destroyProcess",int.class, boolean.class);
                }
                DESTROY_PROCESS.setAccessible(true);
            } catch (ClassNotFoundException e) {
                LinkageError x = new LinkageError();
                x.initCause(e);
                throw x;
            } catch (NoSuchFieldException e) {
                LinkageError x = new LinkageError();
                x.initCause(e);
                throw x;
            } catch (NoSuchMethodException e) {
                LinkageError x = new LinkageError();
                x.initCause(e);
                throw x;
            }
        }

The signature of UNIXProcess.destoryProcess changed in Java 8. Java 9 and forward may have made further changes. You'll need a JDK that has what Jenkins wants to find in that class.

Jonathan Ross
  • 530
  • 3
  • 10