'Exception in thread "main" java.lang.NoClassDefFoundError in the eclipse
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import io.github.bonigarcia.wdm.WebDriverManager;
public class TestFindingElement {
public static void main(String[] args) {
WebDriverManager.chromedriver().setup();
WebDriver driver=new ChromeDriver();
driver.get("http://google.com");
}
}
When I execute the above code in the eclipse. Throwing the following error.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hc/core5/http/ClassicHttpRequest at testcases.TestFindingElement.main(TestFindingElement.java:14) Caused by: java.lang.ClassNotFoundException: org.apache.hc.core5.http.ClassicHttpRequest at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 1 more
I check the classpath and did refresh the project still getting the same error. however, When I ran the simple print statement no error will be display. please help me I am so frustrated with the error for two days.
Solution 1:[1]
If it's a maven project, add this dependency to your POM.xml:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Eric Aya |