2013-12-16 68 views
2

使用S3服務時,我試圖從所有桶中檢索列表。雖然我正在執行此操作,但我得到一個異常。使用Jets3t獲取s3中桶的列表時出現異常

我得到一個S3服務異常:java.lang.Long不能轉換爲java.lang.Integer。

下面是代碼:

String awsKey = "awskey"; 
    String awsSecret = "secret"; 
    AWSCredentials aws = new AWSCredentials(awsKey,awsSecret); 

    //communicate with s3 
    try{ 
    S3Service service = new RestS3Service(aws); 

    //get buckets 
    S3Bucket[] buckets = service.listAllBuckets(); 

這裏是堆棧跟蹤:

<code> org.jets3t.service.S3ServiceException: Request Error:    java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer 
at org.jets3t.service.S3Service.listAllBuckets(S3Service.java:1370) 
at UploadToS3.main(UploadToS3.java:20) Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer 
at org.apache.http.params.AbstractHttpParams.getIntParameter(AbstractHttpParams.java:70) 
at org.apache.http.client.params.HttpClientParamConfig.getRequestConfig(HttpClientParamConfig.java:54) 
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:806) 
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) 
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57) 
at org.jets3t.service.impl.rest.httpclient.RestStorageService.performRequest(RestStorageService.java:334) 
at org.jets3t.service.impl.rest.httpclient.RestStorageService.performRequest(RestStorageService.java:281) 
at org.jets3t.service.impl.rest.httpclient.RestStorageService.performRestGet(RestStorageService.java:981) 
at org.jets3t.service.impl.rest.httpclient.RestStorageService.listAllBucketsImpl(RestStorageService.java:1373) 
at org.jets3t.service.StorageService.listAllBucketsImpl(StorageService.java:1379) 
at org.jets3t.service.StorageService.listAllBuckets(StorageService.java:563) 
at org.jets3t.service.S3Service.listAllBuckets(S3Service.java:1367) 

任何幫助,將不勝感激。 謝謝。

+0

你可以添加stacktrace嗎? – BobTheBuilder

回答

6

這是一個http客戶端的問題,不得不使用舊版本。

正在使用4.3.1,不得不使用4.2。

0

問題已修復,但未發佈(HTTPCLIENT-1418)。 查找Apache HttpComponents HttpClient 4.3.2版中的修復程序。