NoClassDefFoundError: org/hamcrest/SelfDescribing

I hit the following issue while trying to run a JUnit test in Eclipse:

initializationError
The Failure Trace displayed a message stating java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing

initializationError while running Junit Test

I made sure that I had JUnit 4 and org.hamcrest.core along with the Java library in my project but still faced this issue.

After analyzing quite a bit, I noticed that my JRE System Library also has JUnit files associated. I added the org.hamcrest.core_1xx.jar to my JRE path as shown below.

Adding Hamcrest to Java files

I ran the test again. This time the test run was successful.

JunitTest Success


Other links which may help you to solve this issue

I had to Google around quite a bit to find the solution. I noticed there are multiple causes for this issue. If the solution outlined in this blog did not help you, try one of these helpful links:
1. http://stackoverflow.com/questions/14539072/java-lang-noclassdeffounderror-org-hamcrest-selfdescribing
2. http://stackoverflow.com/questions/15190699/eclipse-junit-possible-causes-of-seeing-initializationerror-in-eclipse-windo


Avinash Shetty
I am a software tester with over 10 years of experience in software testing. Currently I am working at Qxf2 Services Bangalore. As a student of the context-driven approach to software testing I feel there is a lot to learn out there which keeps me very excited. My work has helped me gain good experience in different areas of testing like CRM, Web, Mobile and Database testing. I have good knowledge of building test scripts using Automation tools like Selenium and Appium using Java and Python. Beside testing I am a “Sports Fanatic” and love watching and playing sports.

© 2013-2017, Avinash Shetty. All rights reserved.

One Comment

  1. Thanks, that actually worked for me. I don’t know why this did not work right out of the box.

    September 18, 2016
    Reply

Leave a Reply

Your email address will not be published.