每当我尝试通过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的版本之间存在一些冲突,但无论我尝试哪个版本,我都无法弄明白。
.classpath 文件的一部分:
<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);
其中credentials
是AWSCredentials的一个实例。
如果您需要任何其他信息,我很乐意提供。
答案 0 :(得分:2)
有同样的问题。我的解决方案是升级我的AWS版本
def check_events(ai_settings,stats,play_button,screen,ship,aliens,bullets):
for event in pygame.event.get():
if event.type==pygame.QUIT:
sys.exit()
elif event.type==pygame.KEYDOWN:
check_keydown_events(event,ai_settings,screen,ship,bullets)
elif event.type==pygame.KEYUP:
check_keyup_events(event,ship)
elif event.type==pygame.MOUSEBUTTONDOWN:
mouse_x,mouse_y=pygame.mouse.get_pos()
check_play_button(ai_settings,screen,ship,aliens,bullets,stats,play_button,mouse_x,mouse_y)
def check_play_button(ai_settings,screen,stats,play_button,ship,aliens,bullets,mouse_x,mouse_y):
button_clicked=play_button.rect.collidepoint(mouse_x,mouse_y)
if button_clicked and not stats.game_active:
pygame.mouse.set_visible(False)
stats.reset_stats()
stats.game_active=True
aliens.empty()
bullets.empty()
create_fleet(ai_settings,screen,ship,aliens)
ship.center_ship()
pom.xml中的从<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
到<version>1.10.77</version>
答案 1 :(得分:1)
确保您的核心版本和s3版本相同。
我在获取beforeClientExecution的java.lang.NoSuchMethodError
这对我有用
compile('com.amazonaws:aws-java-sdk-core:1.11.376')
compile('com.amazonaws:aws-java-sdk-s3:1.11.376')
答案 2 :(得分:0)
我遇到了同样的问题。我能够通过制作我的JustClip of httpClient并使其成为Project-&gt;中的顶级jar来解决它。 RightCLick-&gt; Java BuildPath-&gt;订单和导出
答案 3 :(得分:0)