我已經看到this,但沒有解釋我的問題的答案。我第一次使用提供的示例here(GetObject類),它立即在我的桌面上工作。但是,我的朋友無法在他的機器上工作,也不能在我們的EC2實例上工作。AWS錯誤從S3下載對象,「配置文件不能爲空」
有人提到,要指定憑據文件,這是有道理的,但我從來沒有這樣做,並且非常確定默認權限設置爲允許訪問此存儲桶。
這裏的堆棧跟蹤:
Exception in thread "main" java.lang.IllegalArgumentException: profile file cannot be null
at com.amazonaws.util.ValidationUtils.assertNotNull(ValidationUtils.java:37)
at com.amazonaws.auth.profile.ProfilesConfigFile.<init>(ProfilesConfigFile.java:142)
at com.amazonaws.auth.profile.ProfilesConfigFile.<init>(ProfilesConfigFile.java:133)
at com.amazonaws.auth.profile.ProfilesConfigFile.<init>(ProfilesConfigFile.java:100)
at com.amazonaws.auth.profile.ProfileCredentialsProvider.getCredentials(ProfileCredentialsProvider.java:135)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.getCredentialsFromContext(AmazonHttpClient.java:1029)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1049)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:949)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:662)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:636)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:619)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$300(AmazonHttpClient.java:587)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:574)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:446)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4035)
at com.amazonaws.services.s3.AmazonS3Client.getBucketRegionViaHeadRequest(AmazonS3Client.java:4474)
at com.amazonaws.services.s3.AmazonS3Client.fetchRegionFromCache(AmazonS3Client.java:4448)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4020)
at com.amazonaws.services.s3.AmazonS3Client.getObject(AmazonS3Client.java:1307)
at GetObject.main(GetObject.java:26)
我可以保證,無論是bucketName也不在GetObjectRequest關鍵PARAMS是空的。這裏有什麼差異?爲什麼它只能在我的電腦上成功?這一切都與我必須補充aws-sdk jar應該已經有的許多罐子(jackson-databind,jackson-core,jackson-annotations,httpclient,httpcore,commons-logging和joda-時間)?這看起來很相似,其他的莫名其妙的錯誤(給出非空params,aws-sdk中的某些內容表示它爲空)。
不知道你是否看到過這個:http://stackoverflow.com/a/41670728/3770040 –
我仍在調查你的鏈接和「與AWS憑證一起工作」頁面鏈接,但我從來沒有設置這些爲我的eclipse項目,我沒有一個憑證文件。我剛開始運行這個開箱即用的例子,它工作正常。我仍然很困惑。 – Xenalin
好的,我認爲我發現了這個問題:我認爲證書已經存儲在項目文件夾中,但我完全忘記了〜/ .aws/credentials文件,儘管從鏈接問題中以黑白方式讀取它。我只需要知道如何爲我的EC2實例上運行的jar設置它。 – Xenalin