Weird Jenkins Error: java.lang.NoClassDefFoundError: hudson/model/ComputerSet

I finally got passed that Jenkins NoClassDefFound error when managing nodes… Now no such errors and the system was back. The slave machines are back to work and projects are building now!

The Jenkins error message (the log jenkins.log is under /var/log/jenkins/ in a standard standalone Linux installation) does not make sense and was misleading:

May 29, 2012 3:03:32 PM hudson.triggers.SafeTimerTask run

SEVERE: Timer task hudson.model.LoadStatistics$LoadStatisticsUpdater@12c8855 failed

java.lang.NoClassDefFoundError: hudson/model/ComputerSet

at hudson.model.LoadStatistics$LoadStatisticsUpdater.doRun(LoadStatistics.java:215)

at hudson.triggers.SafeTimerTask.run(SafeTimerTask.java:54)

at java.util.TimerThread.mainLoop(Timer.java:512)

The class was there. We just need to remove nodeMonitor.xml when migrating Jenkins instance.

nodeMonitors.xml: when migrating to another instance of Jenkins, remove the old nodeMonitors.xml to solve that NoClassDefFound erroe/issue as follows:

sudo  mv /var/lib/jenkins/nodeMonitors.xml /var/lib/jenkins/nodeMonitors.xml.old

nodeMonitors.xml will be automatically generated.

During the time I tried to resolve the issue, I also tweaked the JDK setting in Jenkins config. I added a jdk named jdk1.6-/usr/java/default/bin/java with JAVA_HOME: /usr/java/default

Be sure to take this out in Jenkins config if you are using slaves; it depends on slave machines env varianle JAVA_HOME. Adding this only confuses the salve machine as this overrides its local JAVA_HOME setting. If your master machine is Linux and your slave machine is Windows(like for building .net applications we we also are doing, in addition to Java jobs), this will definitely cause an error: incorrect JDK home.