当前位置: 首页 > 知识库问答 >
问题:

AWS SDK:java。lang.NoSuchMethodError

耿锦
2023-03-14

每当我尝试通过AWS SDK发送邮件时,都会出现以下异常:

java.lang.NoSuchMethodError: org.apache.http.params.HttpConnectionParams.setSoKeepalive(Lorg/apache/http/params/HttpParams;Z)V

我在这里得到了一个提示(https://github.com/aws/aws-sdk-java/issues/422)可能有什么问题:显然HttpClient和HttpCore版本之间存在一些冲突,但无论我尝试哪个版本,我都无法弄清楚。

的一部分。类路径文件:

<classpathentry kind="lib" path="lib/aws-java-sdk-1.10.69-javadoc.jar"/>
<classpathentry kind="lib" path="lib/aws-java-sdk-1.10.69-sources.jar"/>
<classpathentry kind="lib" path="lib/aws-java-sdk-1.10.69.jar"/>
<classpathentry kind="lib" path="lib/aws-java-sdk-flow-build-tools-1.10.69.jar"/>
<classpathentry kind="lib" path="lib/httpclient-4.3.6.jar"/>
<classpathentry kind="lib" path="lib/httpcore-4.3.3.jar"/>
<classpathentry kind="lib" path="lib/google-http-client-1.18.0-rc.jar"/>
<classpathentry kind="lib" path="lib/google-http-client-appengine-1.18.0-rc.jar"/>
<classpathentry kind="lib" path="lib/google-http-client-gson-1.18.0-rc.jar"/>
<classpathentry kind="lib" path="lib/google-http-client-jackson2-1.18.0-rc.jar"/>
<classpathentry kind="lib" path="lib/google-http-client-jdo-1.18.0-rc.jar"/>
<classpathentry kind="lib" path="lib/httpmime-4.1.3.jar"/

完成异常printStack():

java.lang.NoSuchMethodError: org.apache.http.params.HttpConnectionParams.setSoKeepalive(Lorg/apache/http/params/HttpParams;Z)V
at com.amazonaws.http.HttpClientFactory.createHttpClient(HttpClientFactory.java:96) ~[aws-java-sdk-1.10.69.jar:?]
at com.amazonaws.http.AmazonHttpClient.<init>(AmazonHttpClient.java:187) ~[aws-java-sdk-1.10.69.jar:?]
at com.amazonaws.AmazonWebServiceClient.<init>(AmazonWebServiceClient.java:136) ~[aws-java-sdk-1.10.69.jar:?]
at com.amazonaws.AmazonWebServiceClient.<init>(AmazonWebServiceClient.java:120) ~[aws-java-sdk-1.10.69.jar:?]
at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.<init>(AmazonSimpleEmailServiceClient.java:165) ~[aws-java-sdk-1.10.69.jar:?]
at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.<init>(AmazonSimpleEmailServiceClient.java:145) ~[aws-java-sdk-1.10.69.jar:?]
at com.fieldoo.service.MailService.send(MailService.java:259) ~[classes/:?]
at com.fieldoo.service.MailService.checkAndSendQueue(MailService.java:222) ~[classes/:?]
at com.fieldoo.service.MailService$$FastClassByCGLIB$$ce530a4.invoke(<generated>) ~[cglib-nodep-2.2.jar:?]
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191) ~[cglib-nodep-2.2.jar:?]
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:689) ~[org.springframework.aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) ~[org.springframework.aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) ~[org.springframework.transaction-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) ~[org.springframework.aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622) ~[org.springframework.aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at com.fieldoo.service.MailService$$EnhancerByCGLIB$$382d8989.checkAndSendQueue(<generated>) ~[cglib-nodep-2.2.jar:?]
at com.fieldoo.controller.ScheduleController.sendEmails(ScheduleController.java:196) ~[classes/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_04]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_04]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_04]
at java.lang.reflect.Method.invoke(Method.java:601) ~[?:1.7.0_04]
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:64) ~[org.springframework.context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53) [org.springframework.context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) [org.springframework.context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [?:1.7.0_04]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [?:1.7.0_04]
at java.util.concurrent.FutureTask.run(FutureTask.java:166) [?:1.7.0_04]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) [?:1.7.0_04]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) [?:1.7.0_04]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [?:1.7.0_04]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [?:1.7.0_04]
at java.lang.Thread.run(Thread.java:722) [?:1.7.0_04]

此异常由以下代码行引起:

AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(credentials);

其中凭据是AWS凭据的一个实例。
如果您需要任何其他信息,我很乐意提供。

共有3个答案

富勇军
2023-03-14

我也面临着同样的问题。我能够通过制作我的只是制作httpClient的顺序并将其作为我在Project-中的顶级jar来解决它

张绍晖
2023-03-14

有同样的问题。我的解决方案是升级AWS版本

<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>

的pom.xml中

庄子平
2023-03-14

确保您的核心版本和s3版本相同。

我java.lang.NoSuchmetodError for beforeClientExecution

这对我有用

compile('com.amazonaws:aws-java-sdk-core:1.11.376')
compile('com.amazonaws:aws-java-sdk-s3:1.11.376')
 类似资料: