{"id":1974,"date":"2014-11-04T11:32:29","date_gmt":"2014-11-04T16:32:29","guid":{"rendered":"http:\/\/qxf2.com\/blog\/?p=1974"},"modified":"2015-04-12T08:43:22","modified_gmt":"2015-04-12T12:43:22","slug":"initialization-error-hamcrest","status":"publish","type":"post","link":"https:\/\/qxf2.com\/blog\/initialization-error-hamcrest\/","title":{"rendered":"NoClassDefFoundError: org\/hamcrest\/SelfDescribing"},"content":{"rendered":"<p>I hit the following issue while trying to run a JUnit test in Eclipse:<br \/>\n <\/p>\n<div style=\"background-color: #ffff99;\">\n<strong>initializationError<\/strong><br \/>\nThe Failure Trace displayed a message stating java.lang.NoClassDefFoundError: org\/hamcrest\/SelfDescribing\n<\/div>\n<p>\n<a href=\"http:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/11\/Hamcrest-Issue.jpg\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/11\/Hamcrest-Issue-1024x474.jpg\" alt=\"initializationError while running Junit Test\" width=\"1024\" height=\"474\" class=\"aligncenter size-large wp-image-1975\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/11\/Hamcrest-Issue-1024x474.jpg 1024w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/11\/Hamcrest-Issue-300x139.jpg 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/11\/Hamcrest-Issue.jpg 1346w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>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. <\/p>\n<p>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.<br \/>\n<br \/>\n<a href=\"http:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/11\/Adding-Hamcrest-to-Java-files.jpg\" data-rel=\"lightbox-image-1\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/11\/Adding-Hamcrest-to-Java-files.jpg\" alt=\"Adding Hamcrest to Java files\" width=\"749\" height=\"454\" class=\"aligncenter size-full wp-image-1976\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/11\/Adding-Hamcrest-to-Java-files.jpg 749w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/11\/Adding-Hamcrest-to-Java-files-300x181.jpg 300w\" sizes=\"auto, (max-width: 749px) 100vw, 749px\" \/><\/a><br \/>\n<br \/>\nI ran the test again. This time the test run was successful.<br \/>\n<br \/>\n<a href=\"http:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/11\/JunitTestSuccess.jpg\" data-rel=\"lightbox-image-2\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/11\/JunitTestSuccess-1024x275.jpg\" alt=\"JunitTest Success\" width=\"1024\" height=\"275\" class=\"aligncenter size-large wp-image-1977\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/11\/JunitTestSuccess-1024x275.jpg 1024w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/11\/JunitTestSuccess-300x80.jpg 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/11\/JunitTestSuccess.jpg 1206w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<hr>\n<h3>Other links which may help you to solve this issue<\/h3>\n<p>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:<br \/>\n1. <a href=\"http:\/\/stackoverflow.com\/questions\/14539072\/java-lang-noclassdeffounderror-org-hamcrest-selfdescribing\">http:\/\/stackoverflow.com\/questions\/14539072\/java-lang-noclassdeffounderror-org-hamcrest-selfdescribing<\/a><br \/>\n2. <a href=\"http:\/\/stackoverflow.com\/questions\/15190699\/eclipse-junit-possible-causes-of-seeing-initializationerror-in-eclipse-windo\">http:\/\/stackoverflow.com\/questions\/15190699\/eclipse-junit-possible-causes-of-seeing-initializationerror-in-eclipse-windo<\/a><\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>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 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 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53,54],"tags":[],"class_list":["post-1974","post","type-post","status-publish","format-standard","hentry","category-java","category-junit"],"_links":{"self":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/1974","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/comments?post=1974"}],"version-history":[{"count":13,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/1974\/revisions"}],"predecessor-version":[{"id":1993,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/1974\/revisions\/1993"}],"wp:attachment":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/media?parent=1974"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/categories?post=1974"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/tags?post=1974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}