Java.lang.NoClassDefFoundError: org / apache / http / conn / scheme / SchemeSocketFactory

I'm trying to send AWSCredentials mail but get an exception

java.lang.NoClassDefFoundError: org / apache / http / conn / scheme / SchemeSocketFactory

I added this jar:

  • AWS-Java-SDK-1.3.11.jar
  • AWS-Java-SDK-1.3.11-javadoc.jar
  • AWS-Java-SDK-1.3.11-sources.jar
  • AWS-Java-KFK-flow-assembly-tools-1.3.11.jar
  • Common-logging.jar
  • HttpClient-4.0-alpha4.jar
  • httpcore-4,0-alpha6.jar
  • log4j-1.2.13.jar
  • mail.jar

My java code is

import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; import com.amazonaws.services.simpleemail.model.*; import java.util.LinkedList; public class SESExample { public static final String ACCESS_KEY = "My Access"; public static final String SECRET_KEY = "My Secret"; public static void main(String args[]) { String sender = " support@brandzter.com "; // should be verified email LinkedList<String> recipients = new LinkedList<String>(); recipients.add(" khoyendra@globussoft.com "); // again a verified email, if you are in sandbox SendMail(sender, recipients, "Hi", "Hi how are u?"); } public static void SendMail(String sender, LinkedList<String> recipients, String subject, String body) { Destination destination = new Destination(recipients); Content subjectContent = new Content(subject); Content bodyContent = new Content(body); Body msgBody = new Body(bodyContent); Message msg = new Message(subjectContent, msgBody); SendEmailRequest request = new SendEmailRequest(sender, destination, msg); AWSCredentials credentials = new BasicAWSCredentials(ACCESS_KEY, SECRET_KEY); AmazonSimpleEmailServiceClient sesClient = new AmazonSimpleEmailServiceClient(credentials); SendEmailResult result = sesClient.sendEmail(request); System.out.println(result); } 

}

I am also trying to look for this jar, but not getting it. I am using the wrong jar not sure. can anyone tell me what the problem is?

I

+6
source share
5 answers

From javadocs, the SchemeSocketFactory class is available only from version 4.1. So this may have something to do with the fact that you are using 4.0 alpha banks. Try updating your http-client library to version 4.1 or higher.

+18
source

From javadoc , it seems that the class org/apache/http/conn/scheme/SchemeSocketFactory existed since version 4.1.

So, try updating your httpclient jar to at least version 4.1.

+2
source

If you download the latest aws java SDK (I just downloaded aws-java-sdk-1.9.3),

necessary libraries will be in third-party folders / ** / lib. Their bunch!

This answer from jomofrodo needs more attention. Nailed it. Thanks!

+2
source

In my case, I had two libraries that I created in Netbeans 7.2: one for Apache Commons Codec 1.6 and one for Apache Commons HttpClient 4.2.2. In this case, since the library I created for HttpClient also contained the Codec 1.6 flag, I got the same error.

Make sure that you do not have two identical libraries specified in your class path, or two conflicting versions of the same library.

+1
source

debug your code and indicate where the exception occurs. Any instance of the class that you used is not included in your jar file, I think so. I'm not sure. find this by debugging. I think SchemeSocketFactory does not exist in your class path. Please check

0
source

Source: https://habr.com/ru/post/918728/


All Articles