Intermittent NoClassDefFoundError error running Selenium JUnit tests
- by Matt Sheppard
For some time, I've been running a substantial set of JUnit / Selenium tests against a number of platforms on a nightly basis. Intermittently (about once in every 40 runs), all the tests for a given platform fail with a NoClassDefFoundError on the common superclass of all my tests as follows.
java.lang.NoClassDefFoundError: [common super class of all my selenium tests]
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructors(Class.java:1459)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
Re-invoking the tests will generally get the tests running normally, so it's clearly something dependent on some condition I am not considering.
What might be causing this error to occur seemingly randomly?