使用AWS SDK 1.11.97在HandlerChainFactory.getGlobalHandlers()上出现NoSuchMethod错误

时间:2017-02-26 00:46:05

标签: amazon-web-services amazon-s3 playframework nosuchmethoderror

我有一个我正在研究的游戏2.4.3框架应用程序。我刚刚将图像添加到AWS S3存储桶,我在本地工作。但是当我推送到AWS弹性Beanstalk环境时,当我尝试按these instructions创建AmazonS3Client时出现以下错误:

java.lang.NoSuchMethodError: com.amazonaws.handlers.HandlerChainFactory.getGlobalHandlers()Ljava/util/List;
    at com.amazonaws.services.s3.AmazonS3Client.init(AmazonS3Client.java:668) ~[com.amazonaws.aws-java-sdk-s3-1.11.97.jar:na]
    at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:651) ~[com.amazonaws.aws-java-sdk-s3-1.11.97.jar:na]
    at com.amazonaws.services.s3.AmazonS3Builder$1.apply(AmazonS3Builder.java:35) ~[com.amazonaws.aws-java-sdk-s3-1.11.97.jar:na]
    at com.amazonaws.services.s3.AmazonS3Builder$1.apply(AmazonS3Builder.java:32) ~[com.amazonaws.aws-java-sdk-s3-1.11.97.jar:na]
    at com.amazonaws.services.s3.AmazonS3ClientBuilder.build(AmazonS3ClientBuilder.java:64) ~[com.amazonaws.aws-java-sdk-s3-1.11.97.jar:na]
    at com.amazonaws.services.s3.AmazonS3ClientBuilder.build(AmazonS3ClientBuilder.java:28) ~[com.amazonaws.aws-java-sdk-s3-1.11.97.jar:na]
    at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:38) ~[com.amazonaws.aws-java-sdk-core-1.11.43.jar:na]
    at utils.image.ImageUtils.getCredentaledS3Client(ImageUtils.java:49) ~[richfoods.richfoods-1.0-SNAPSHOT-sans-externalized.jar:na]
    at utils.image.ImageUtils.save(ImageUtils.java:152) ~[richfoods.richfoods-1.0-SNAPSHOT-sans-externalized.jar:na]
    at utils.image.ImageUtils.createCroppedSquareProxy(ImageUtils.java:93) ~[richfoods.richfoods-1.0-SNAPSHOT-sans-externalized.jar:na]
    at controllers.ControllerUtils.saveImage(ControllerUtils.java:155) ~[richfoods.richfoods-1.0-SNAPSHOT-sans-externalized.jar:na]
    at controllers.user.ModelController.onProfileSubmit(ModelController.java:193) ~[richfoods.richfoods-1.0-SNAPSHOT-sans-externalized.jar:na]
    at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$18$$anonfun$apply$18.apply(Routes.scala:868) ~[richfoods.richfoods-1.0-SNAPSHOT-sans-externalized.jar:na]
    at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$18$$anonfun$apply$18.apply(Routes.scala:868) ~[richfoods.richfoods-1.0-SNAPSHOT-sans-externalized.jar:na]
    at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:136) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.core.routing.HandlerInvokerFactory$JavaActionInvokerFactory$$anon$14$$anon$3$$anon$1.invocation(HandlerInvoker.scala:127) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:70) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.GlobalSettings$1.call(GlobalSettings.java:67) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at models.privilege.Authentication$User.call(Authentication.java:51) ~[richfoods.richfoods-1.0-SNAPSHOT-sans-externalized.jar:na]
    at play.core.j.JavaAction$$anonfun$7.apply(JavaAction.scala:94) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.core.j.JavaAction$$anonfun$7.apply(JavaAction.scala:94) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) ~[org.scala-lang.scala-library-2.11.6.jar:na]
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) ~[org.scala-lang.scala-library-2.11.6.jar:na]
    at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.scala:40) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.api.libs.iteratee.Execution$trampoline$.execute(Execution.scala:70) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
    at play.core.j.HttpExecutionContext.execute(HttpExecutionContext.scala:32) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at scala.concurrent.impl.Future$.apply(Future.scala:31) ~[org.scala-lang.scala-library-2.11.6.jar:na]
    at scala.concurrent.Future$.apply(Future.scala:492) ~[org.scala-lang.scala-library-2.11.6.jar:na]
    at play.core.j.JavaAction.apply(JavaAction.scala:94) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:105) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:105) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:104) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:103) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at scala.Option.map(Option.scala:146) ~[org.scala-lang.scala-library-2.11.6.jar:na]
    at play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:103) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:96) ~[com.typesafe.play.play_2.11-2.4.3.jar:2.4.3]
    at play.api.libs.iteratee.Iteratee$$anonfun$mapM$1.apply(Iteratee.scala:524) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
    at play.api.libs.iteratee.Iteratee$$anonfun$mapM$1.apply(Iteratee.scala:524) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
    at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM$1.apply(Iteratee.scala:560) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
    at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM$1.apply(Iteratee.scala:560) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
    at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$1$$anonfun$apply$14.apply(Iteratee.scala:537) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
    at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$1$$anonfun$apply$14.apply(Iteratee.scala:537) ~[com.typesafe.play.play-iteratees_2.11-2.4.3.jar:2.4.3]
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) ~[org.scala-lang.scala-library-2.11.6.jar:na]
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) ~[org.scala-lang.scala-library-2.11.6.jar:na]
    at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40) ~[com.typesafe.akka.akka-actor_2.11-2.3.13.jar:na]
    at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397) [com.typesafe.akka.akka-actor_2.11-2.3.13.jar:na]
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [org.scala-lang.scala-library-2.11.6.jar:na]
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [org.scala-lang.scala-library-2.11.6.jar:na]
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [org.scala-lang.scala-library-2.11.6.jar:na]
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [org.scala-lang.scala-library-2.11.6.jar:na]

我无法通过谷歌搜索找到任何相关信息。有任何想法吗? 我使用Docker让应用程序在EB上运行。但我没有使用Docker在本地运行。我想知道这可能与它有关吗?

2 个答案:

答案 0 :(得分:0)

我希望你找到了答案 - 几乎可以肯定是依赖版本问题。

我看到了同样的问题,但是在Spring Boot应用程序中。在本地工作正常,但我在同一个类和方法上得到相同的NoSuchMethodException。

我很确定我们在部署到AWS时看到它的原因是因为IAM角色以及如何确定凭据。

答案 1 :(得分:0)

听起来像EB正在覆盖S3 SDK lib(aws-java-sdk-s3)的基本依赖关系,或者你的构建中存在一些错误的依赖元数据 - 我不熟悉构建Play应用程序,我猜测这会创建一个带有捆绑依赖关系的可运行JAR吗?

我在本地的Spring Boot项目中遇到了同样的问题。最后对我来说,这是由于Intellij IDEA提供过时的依赖关系(明确重新指定基本依赖关系并重新构建问题)。

<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-core</artifactId>
    <version>${aws.api.version}</version>
</dependency>
<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-kms</artifactId>
    <version>${aws.api.version}</version>
</dependency>

尝试直接在-core中指定-kms(可能还有pom.xml)相关性(如果您使用Gradle构建,则build.gradle)。

编辑:我看到Play使用SBT!所以我猜那里的语法不同。