NoSuchMethodError exception in uber jar NoSuchMethodError exception in uber jar selenium selenium

NoSuchMethodError exception in uber jar


It is a transitive dependency problem, it means that you have jars which have this class each having version of that class where this method is not present and by default maven loads that class which it gets first, you can check the class by pressing Ctrl+Shift+T, you can see multiple versions of that class, once you find the class which will not be having that method, in pom.xml for that .jar which contains that file write exclusion for that.


From exception it appears that selenium-htmlunit-driver (conclusion from seeing com.gargoylesoftware.htmlunit in exception) cannot find org.apache.httpcomponents.httpclient v. 4.4 or higher (conclusion from looking up in which package SSLConnectionSocketFactory is; more specifically it wants version 4.4 or above of this lib, since the method it cannot find is introduced in version 4.4,see here). Also if you look at dependencies of selenium-htmlunit-driver, it looks like it's using version 4.5.1. So include the following into your dependencies:

<dependency>    <groupId>org.apache.httpcomponents</groupId>    <artifactId>httpclient</artifactId>    <version>4.5.1</version></dependency>

so that it packages this lib with your JAR. And of course make sure you don't have another httpclient-x.x.x.jar in the same folder.