NoSuchMethodError: org.apache.http.conn.ssl.SSLConnectionSocketFactory
Asked Answered
T

1

30

I keep getting:

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.http.conn.ssl.SSLConnectionSocketFactory.<init>(Ljavax/net/ssl/SSLContext;Ljavax/net/ssl/HostnameVerifier;)V
at com.amazonaws.http.conn.ssl.SdkTLSSocketFactory.<init>(SdkTLSSocketFactory.java:56)
at com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory.getPreferredSocketFactory(ApacheConnectionManagerFactory.java:87)
at com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory.create(ApacheConnectionManagerFactory.java:65)
at com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory.create(ApacheConnectionManagerFactory.java:58)
at com.amazonaws.http.apache.client.impl.ApacheHttpClientFactory.create(ApacheHttpClientFactory.java:50)
at com.amazonaws.http.apache.client.impl.ApacheHttpClientFactory.create(ApacheHttpClientFactory.java:38)
at com.amazonaws.http.AmazonHttpClient.<init>(AmazonHttpClient.java:253)
at com.amazonaws.AmazonWebServiceClient.<init>(AmazonWebServiceClient.java:145)
at com.amazonaws.AmazonWebServiceClient.<init>(AmazonWebServiceClient.java:136)
at com.amazonaws.AmazonWebServiceClient.<init>(AmazonWebServiceClient.java:121)
at com.amazonaws.services.elasticmapreduce.AmazonElasticMapReduceClient.<init>(AmazonElasticMapReduceClient.java:175)
at com.amazonaws.services.elasticmapreduce.AmazonElasticMapReduceClient.<init>(AmazonElasticMapReduceClient.java:155)
at ExtractRelatedPairs.main(ExtractRelatedPairs.java:30)

Visual description which illustrates all the added jars (on the left) and their version for inspection.

Despite the fact that all needed jars are added, tried all the different jars and versions, even tried to change project's settings to work with 1.6 1.7 instead of 1.8...

Any ideas?

Tessietessier answered 22/6, 2016 at 22:10 Comment(5)
Please add the error message instead of using an image.Knavish
@Knavish Done, thanks for the feedbackTessietessier
Much better, thanks!Knavish
evaluate this while debugging - org.apache.http.conn.ssl.SSLConnectionSocketFactory.class.getProtectionDomain().getCodeSource().getLocation().getPath(). it will give you the currently used httpclient jar version, make sure it is above 4.5.3 and maintain only one jar.Dopester
In case you are using gradle and maven, I followed this approach: https://mcmap.net/q/472482/-caused-by-java-lang-nosuchmethoderror-org-apache-http-conn-ssl-sslconnectionsocketfactoryPastelist
M
70

Assuming your project is built with Maven, adding this to your pom.xml should take care of that issue:

<dependency>
  <groupId>org.apache.httpcomponents</groupId>
  <artifactId>httpclient</artifactId>
  <version>4.5.2</version>
</dependency>
Moldboard answered 6/7, 2016 at 21:8 Comment(7)
Thanks for the tip. Could you explain what exactly this solves and what the root issue was?Contravention
@YuChen The class in an older jar does not have the required constructor.Seiden
Or better look through dependency hierarchy for conflicting dependency and add an exclusion.Alfaro
can you explain what's a pom?Tooley
@Tooley a pom is an XML file for managing various aspects of your project, including dependencies. You'll want to look into Maven for more information: maven.apache.org/pom.htmlMonamonachal
@RobertVažan could you please explain a bit on where I can find dependency hierarchy or finding conflicting dependency? Or if you could point me to a source to learn related concept that'd be awesome. Thanks!Flap
@RandomCertainty Dependency hierarchy is a tab in Eclipse's view of pom.xml. I don't know about other IDEs/tools.Alfaro

© 2022 - 2024 — McMap. All rights reserved.