Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError: org/apache/hc/core5/http/ClassicHttpRequest on WebDriverManager 5.3.2 #993

Closed
Ya-s-h opened this issue Feb 15, 2023 · 5 comments
Labels

Comments

@Ya-s-h
Copy link

Ya-s-h commented Feb 15, 2023

Got this error on WebDriverManager 5.3.2 java.lang.NoClassDefFoundError: org/apache/hc/core5/http/ClassicHttpRequest when Using Chrome 109 on windows 11

CODE
package main.java.test.java.seleniumE2E;

import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class ChromeTest {
static WebDriver driver;
@BeforeMethod
static void setupClass() {
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
}
@AfterMethod
void teardown() {
driver.quit();
}
@test
void test() {
// Exercise
driver.get("https://bonigarcia.dev/selenium-webdriver-java/");
}
}

Error Message
java.lang.NoClassDefFoundError: org/apache/hc/core5/http/ClassicHttpRequest

at main.java.test.java.seleniumE2E.ChromeTest.setupClass(ChromeTest.java:21)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:134)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:63)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:348)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:302)
at org.testng.internal.TestInvoker.runConfigMethods(TestInvoker.java:695)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:523)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:816)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.testng.TestRunner.privateRun(TestRunner.java:766)
at org.testng.TestRunner.run(TestRunner.java:587)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
at org.testng.SuiteRunner.run(SuiteRunner.java:286)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1109)
at org.testng.TestNG.runSuites(TestNG.java:1039)
at org.testng.TestNG.run(TestNG.java:1007)
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)

Caused by: java.lang.ClassNotFoundException: org.apache.hc.core5.http.ClassicHttpRequest
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 32 more

Test ignored.

===============================================
Default Suite
Total tests run: 1, Passes: 0, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 1

Process finished with exit code 0

@MariusDK
Copy link
Contributor

A suggestion is to add dependency on application pom

org.apache.httpcomponents.client5
httpclient5
5.2.1

This way I've resolved the issue

@bonigarcia
Copy link
Owner

Thanks for you comment @MariusDK. Indeed, this a dependency problem. Please check the required version for org.apache.httpcomponents.client5 is your project, @Ya-s-h.

@Mowee
Copy link

Mowee commented Apr 12, 2023

@bonigarcia Will this dependency be added by a future release?

@bonigarcia
Copy link
Owner

@Mowee httpclient5 is transitive dependency in WedDriverManager. The version of that dependency is fixed in the project docker-java, but they are not very responsive related to bumping dependencies (see e.g. #916 or here).

@Mowee
Copy link

Mowee commented Apr 14, 2023

@bonigarcia Thank you for the explanation. I just thought this could be added as a dependency so that not everyone needs to add this dependency manually. But I get your point. Would be nice if they just fix it upstream. Thx for your great work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants