2

首先简要概述一下:我有一个 iphone 应用程序和一个在 heroku 上运行的 Java PLay(2.1.1) 框架应用程序,我还有 Amazon S3 来存储一些上传的图像。所以基本上 iPhone 应用程序将图像发送到 java 应用程序,然后在上传后将其传输到 S3,然后我有一个页面,您可以查看该上传的图像。

现在的问题是,当我第一次部署应用程序时,一切正常,但几天后,连接似乎无法连接到 S3,我只是收到内部服务器错误:

@6ekb4bp0a - Internal server error, for (GET) [/view/51c0b5d3e4b082764a289889] ->
2013-06-20T08:59:39.318089+00:00 app[web.1]: 
2013-06-20T08:59:38.727484+00:00 heroku[router]: at=info method=GET path=/view/51c0b5d3e4b082764a289889 host=myapp.co.uk fwd="---.---.---.--" dyno=web. connect=1ms service=27ms status=500 bytes=1941
2013-06-20T08:59:39.422984+00:00 app[web.1]: play.api.Application$$anon$1: Execution exception[[RuntimeException: java.lang.NoSuchMethodError: org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager: method <init>()V not found]]
2013-06-20T08:59:39.523670+00:00 app[web.1]:    at play.api.Application$class.handleError(Application.scala:289) ~[play_2.10-2.1.1.jar:2.1.1]
2013-06-20T08:59:39.621627+00:00 app[web.1]:    at play.api.DefaultApplication.handleError(Application.scala:383) [play_2.10-2.1.1.jar:2.1.1]
2013-06-20T08:59:39.722105+00:00 app[web.1]:    at play.core.server.netty.PlayDefaultUpstreamHandler$$anon$2$$anonfun$handle$1.apply(PlayDefaultUpstreamHandler.scala:144) [play_2.10-2.1.1.jar:2.1.1]
2013-06-20T08:59:39.819446+00:00 app[web.1]:    at play.core.server.netty.PlayDefaultUpstreamHandler$$anon$2$$anonfun$handle$1.apply(PlayDefaultUpstreamHandler.scala:140) [play_2.10-2.1.1.jar:2.1.1]
2013-06-20T08:59:39.916774+00:00 app[web.1]:    at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10-        2.1.1.jar:2.1.1]
2013-06-20T08:59:40.015921+00:00 app[web.1]:    at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10-2.1.1.jar:2.1.1]
2013-06-20T08:59:40.113516+00:00 app[web.1]: java.lang.RuntimeException: java.lang.NoSuchMethodError: org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager: method <init>()V not found
2013-06-20T08:59:40.211257+00:00 app[web.1]:    at play.mvc.Security$AuthenticatedAction.call(Security.java:47) ~[play_2.10-2.1.1.jar:2.1.1]
2013-06-20T08:59:40.317848+00:00 app[web.1]:    at play.core.j.JavaAction$$anon$2.apply(JavaAction.scala:74) ~[play_2.10-2.1.1.jar:2.1.1]
2013-06-20T08:59:40.416593+00:00 app[web.1]:    at play.core.j.JavaAction$$anon$2.apply(JavaAction.scala:73) ~[play_2.10-2.1.1.jar:2.1.1]
2013-06-20T08:59:40.514600+00:00 app[web.1]:    at play.libs.F$Promise$PromiseActor.onReceive(F.java:420) ~[play_2.10-2.1.1.jar:2.1.1]
2013-06-20T08:59:40.612653+00:00 app[web.1]:    at akka.actor.UntypedActor$$anonfun$receive$1.applyOrElse(UntypedActor.scala:159) ~[akka-actor_2.10-2.1.0.jar:na]
2013-06-20T08:59:40.710218+00:00 app[web.1]:    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:425) ~[akka-actor_2.10-2.1.0.jar:na]
2013-06-20T08:59:40.809756+00:00 app[web.1]: Caused by: java.lang.NoSuchMethodError: org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager: method <init>()V not found
2013-06-20T08:59:40.907239+00:00 app[web.1]:    at com.amazonaws.http.ConnectionManagerFactory.createThreadSafeClientConnManager(ConnectionManagerFactory.java:26) ~[aws-java-sdk-1.4.2.1.jar:na]
2013-06-20T08:59:41.006986+00:00 app[web.1]:    at com.amazonaws.http.HttpClientFactory.createHttpClient(HttpClientFactory.java:95) ~[aws-java-sdk-1.4.2.1.jar:na]
2013-06-20T08:59:41.104293+00:00 app[web.1]:    at com.amazonaws.http.AmazonHttpClient.<init>(AmazonHttpClient.java:118) ~[aws-java-sdk-1.4.2.1.jar:na]
2013-06-20T08:59:41.204123+00:00 app[web.1]:    at com.amazonaws.AmazonWebServiceClient.<init>(AmazonWebServiceClient.java:65) ~[aws-java-sdk-1.4.2.1.jar:na]
2013-06-20T08:59:41.302700+00:00 app[web.1]:    at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:298) ~[aws-java-sdk-1.4.2.1.jar:na]
2013-06-20T08:59:41.409163+00:00 app[web.1]:    at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:280) ~[aws-java-sdk-1.4.2.1.jar:na]

当我尝试使用此代码从 S3 检索图像时会发生这种情况(我很确定这是我在视图上使用 S3 的唯一位置):

    public static String generateS3Url(String filename, int minutes) {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.MINUTE, minutes);
        Date expDate = cal.getTime();
        try {
            BasicAWSCredentials cre = new BasicAWSCredentials(Play.application().configuration().getString("amazons3.accessKey"), Play.application().configuration().getString("amazons3.secretKey"));
            AmazonS3 s3 = new AmazonS3Client(cre);
            String url = s3.generatePresignedUrl(BUCKET_NAME, filename, expDate, HttpMethod.GET).toString();
            return url;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

正如您所看到的,它为提供的图像名称创建了一个临时 url,这在本地也可以使用完全相同的详细信息并在服务器上运行一段时间。你认为它需要每隔一段时间重新启动一次吗?

我希望这是足够的信息,

谢谢,如果你能帮忙,

富有的

** 编辑 ** Build.scala 依赖项

val appDependencies = Seq(
    // Add your project dependencies here,
    javaCore,
    javaJdbc,
    javaEbean
  )
4

0 回答 0