Skip to content Skip to sidebar Skip to footer

Jenkins: Fatal: Could Not Initialize Class Hudson.util.processtree$unixreflection

FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection java.lang.NoClassDefFoundError: Could not initialize class hudson.util.ProcessTree$UnixReflection at hudson

Solution 1:

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

Solution 2:

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.

Solution 3:

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) {
                LinkageErrorx=newLinkageError();
                x.initCause(e);
                throw x;
            } catch (NoSuchFieldException e) {
                LinkageErrorx=newLinkageError();
                x.initCause(e);
                throw x;
            } catch (NoSuchMethodException e) {
                LinkageErrorx=newLinkageError();
                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.

Post a Comment for "Jenkins: Fatal: Could Not Initialize Class Hudson.util.processtree$unixreflection"