Recently I faced with NoClassDefFoundErrors during unit testing despite all class files were in place. It was quite strange. Furthermore this error happened only on our CI (Linux) server, I couldn't reproduce it on desktop, neither on Windows nor on Linux.

I started to investigate the stack traces and it seemed that the native open method of the FileInputStream was failed. After more investigation by JProfiler I found, that many classLoader.getResourceAsStream invocation happens in our code, but those streams are never closed.

Meanwhile I found this nice writing about Tuning Linux applications which says: "Some Linux applications; for example, a JVM, might require a higher file descriptor limit. If an application can't open files because the file descriptor limit has been exceeded, you might get a NoClassDefFoundError error message."

Then it says how to increase number of file handlers (ulimit -n 2048), but let's rather close the resources guys. It would have been quite unlucky if the application starts saying NoClassDefFoundErrors in the wild after some days.