简体   繁体   English

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

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

I am tring to send mail by AWSCredentials but getting an exception 我想通过AWSCredentials发送邮件但是获得例外

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

I have added these jar: 我添加了这些jar:

  • aws-java-sdk-1.3.11.jar AWS-Java的SDK-1.3.11.jar
  • aws-java-sdk-1.3.11-javadoc.jar AWS-Java的SDK-1.3.11-javadoc.jar
  • aws-java-sdk-1.3.11-sources.jar AWS-Java的SDK-1.3.11-sources.jar
  • aws-java-sdk-flow-build-tools-1.3.11.jar AWS-Java的SDK流 - 构建 - 工具 - 1.3.11.jar
  • commons-logging.jar 公共-logging.jar
  • httpclient-4.0-alpha4.jar HttpClient的-4.0-alpha4.jar
  • httpcore-4.0-alpha6.jar 的HttpCore-4.0-alpha6.jar
  • log4j-1.2.13.jar log4j的-1.2.13.jar
  • mail.jar 的mail.jar

My java code is - 我的java代码是 -

 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 search this jar but not getting. 我也试图搜索这个罐子,但没有得到。 Am I using wrong jar not sure. 我使用错误的罐子不确定。 can any one tell me what is the problem? 任何人都可以告诉我这是什么问题?

I am 我是

From the javadocs , the SchemeSocketFactory class is only available since version 4.1. javadocs开始SchemeSocketFactory类仅在4.1版之后可用。 So this might have something to do with the fact that you are using the 4.0 alpha jars. 所以这可能与您使用4.0 alpha jar这一事实有关。 Try upgrading your http-client library to 4.1 or higher. 尝试将您的http-client库升级到4.1或更高版本。

From the javadoc , it seems that the org/apache/http/conn/scheme/SchemeSocketFactory class exists since the 4.1 version. javadoc开始 ,似乎自4.1版本以来存在org/apache/http/conn/scheme/SchemeSocketFactory类。

So, try to upgrade httpclient jar to at least 4.1 version. 因此,尝试将httpclient jar升级到至少4.1版本。

If you download the latest aws java SDK (I just downloaded aws-java-sdk-1.9.3), 如果你下载最新的aws java SDK(我刚刚下载了aws-java-sdk-1.9.3),

the required libraries will be in the third-party/**/lib folders. 所需的库将位于第三方/ ** / lib文件夹中。 There are a bunch of them! 有一堆他们!

This answer from jomofrodo needs more atention. 来自jomofrodo的答案需要更多的关注。 Nailed it. 搞定了。 Thanks! 谢谢!

In my case, I had two libraries that I created in Netbeans 7.2: one for the Apache Commons Codec 1.6, and one for the Apache Commons HttpClient 4.2.2. 在我的例子中,我有两个我在Netbeans 7.2中创建的库:一个用于Apache Commons Codec 1.6,另一个用于Apache Commons HttpClient 4.2.2。 In this case, because the library I made for HttpClient also contained the Codec 1.6 jar, I was getting this same error. 在这种情况下,因为我为HttpClient创建的库也包含Codec 1.6 jar,所以我得到了同样的错误。

Be sure you don't have two of the same libraries referenced in your class path, or two conflicting versions of the same library. 确保您的类路径中没有引用两个相同的库,或者同一个库中的两个冲突版本。

debug your code and point out where Exception occur. 调试代码并指出Exception发生的位置。 Any of instance of class that you used is not included in your jar file i think so. 您使用的任何类实例都不包含在您的jar文件中我认为如此。 am not sure. 我不确定。 find that by debugging. 通过调试找到。 i think SchemeSocketFactory is not exsisting in your class path. 我认为SchemeSocketFactory在您的类路径中不存在。 please check 请检查

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Crawler4j时,线程“ main”中的异常java.lang.NoClassDefFoundError:org / apache / http / conn / scheme / SchemeSocketFactory - Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/http/conn/scheme/SchemeSocketFactory while Using Crawler4j java.lang.NoClassDefFoundError:org / apache / http / conn / HttpClientConnectionManager - java.lang.NoClassDefFoundError: org/apache/http/conn/HttpClientConnectionManager java.lang.NoClassDefFoundError:org / apache / http / nio / conn / NHttpClientConnectionManager - java.lang.NoClassDefFoundError: org/apache/http/nio/conn/NHttpClientConnectionManager java.lang.NoClassDefFoundError:org / apache / http / conn / params / ConnPerRoute - java.lang.NoClassDefFoundError: org/apache/http/conn/params/ConnPerRoute java.lang.NoClassDefFoundError:org / apache / http / impl / conn / PoolingClientConnectionManager - java.lang.NoClassDefFoundError: org/apache/http/impl/conn/PoolingClientConnectionManager java.lang.NoClassDefFoundError:带有AmazonHttpClient的org / apache / http / conn / SchemePortResolver - java.lang.NoClassDefFoundError: org/apache/http/conn/SchemePortResolver with AmazonHttpClient java.lang.NoSuchMethodError:org / apache / http / conn / scheme / Scheme。 <init> (Ljava / lang / String; ILorg / apache / http / conn / scheme / SchemeSocketFactory;)V - java.lang.NoSuchMethodError: org/apache/http/conn/scheme/Scheme.<init>(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V org.apache.http.conn.ssl上的java.lang.NoClassDefFoundError org / apache / commons / logging / LogFactory - java.lang.NoClassDefFoundError org/apache/commons/logging/LogFactory at org.apache.http.conn.ssl Java:java.lang.NoClassDefFoundError:org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager - Java: java.lang.NoClassDefFoundError: org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager java.lang.NoClassDefFoundError: - 不能初始化类org.apache.http.impl.conn.ManagedHttpClientConnectionFactory - java.lang.NoClassDefFoundError :-Could not initialize class org.apache.http.impl.conn.ManagedHttpClientConnectionFactory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM