Sunday, December 18, 2011

JUnit: Testcase: initializationError : java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing

When: Tried to run a JUnit TestCase, I got below error.
Error: JUnit Error.NoClassDefFoundError: org/hamcrest/SelfDescribing
Scenario: I was using Junit.jar 4.0 version
Solution: Use the latest JUnit jar – 4.10.
Reason: Some posts says it as due to the log4j version mismatch b/w what is there in junit jar and the one in Ant jar.
Testcase: initializationError took 0 sec 
Caused an ERROR 
org/hamcrest/
SelfDescribing 
java.lang.
NoClassDefFoundError: org/hamcrest/SelfDescribing 
    at java.lang.
ClassLoader.defineClass1(Native Method) 
    at java.lang.
ClassLoader.defineClass(Unknown Source) 
    at java.security.
SecureClassLoader.defineClass(Unknown Source) 
    at java.net.
URLClassLoader.defineClass(Unknown Source) 
    at java.net.
URLClassLoader.access$000(Unknown Source) 
    at java.net.
URLClassLoader$1.run(Unknown Source) 
    at java.security.
AccessController.doPrivileged(Native Method) 
    at java.net.
URLClassLoader.findClass(Unknown Source) 
    at java.lang.
ClassLoader.loadClass(Unknown Source) 

No comments:

Post a Comment