I have a situation where I get a NoClassDefFoundError. Since there is not much information available, and I am 100% positive that the class is there, I made some detailed testing with Eclipse debugger:
In the Expressions window, I add two expressions:
a) new MyClass() --> leads to NoClassDefFoundError
b) MyClass.class -> shows the Class Definition!?!?
How can that be? I also spied the process with VisualVM and I can see the "MyClass" definition. What can cause such an error when the class is there?
I cannot get a small replicatable example of this case, since I have no clue what causes it. The unit tests of the class can instantiate it, this behaviour only happens in an integrated context.
This can occur if there is a failure while initializing the class
, typically when we have an exception
in static blocks
so you should check all your static blocks
to make sure that none of them throw a RuntimeException
.