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?

Renya Karasuma
  • 1,044
  • 4
  • 11
  • 18

1 Answers1

69

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>
Alex R
  • 11,364
  • 15
  • 100
  • 180
user1902945
  • 726
  • 6
  • 4
  • 1
    Thanks for the tip. Could you explain what exactly this solves and what the root issue was? – Yu Chen May 28 '17 at 22:56
  • 4
    @YuChen The class in an older jar does not have the required constructor. – yurez Jun 21 '17 at 15:17
  • 1
    Or better look through dependency hierarchy for conflicting dependency and add an exclusion. – Robert Važan Jul 06 '17 at 17:25
  • can you explain what's a pom? – bubakazouba Oct 05 '17 at 23:23
  • 1
    @bubakazouba 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: https://maven.apache.org/pom.html – blindsnowmobile Oct 09 '17 at 21:02
  • @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! – Random Certainty Nov 10 '18 at 00:42
  • @RandomCertainty Dependency hierarchy is a tab in Eclipse's view of pom.xml. I don't know about other IDEs/tools. – Robert Važan Nov 11 '18 at 01:16