从 S3 下载对象的 AWS 错误,“配置文件不能为空”
我已经看到了这一点,但没有答案来解释我的问题。我首先使用了此处提供的示例(GetObject 类),它立即在我的桌面上工作。但是,我的朋友无法让它在他的机器上工作,也无法在我们的EC2实例上工作。
有人提到要指定凭证文件,这是有道理的,但我从未这样做过,并且我很确定默认设置了默认权限以允许访问此存储桶。
下面是堆栈跟踪:
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)
我可以保证,GetObjectRequest 中的 bucketName 和 key 参数都不是 null。这里有什么差异?为什么它只能在我的电脑上成功?这是否与以下事实有关:我必须补充aws-sdk jar应该已经拥有的大量jar(jackson-databind,jackson-core,jackson-annotations,httpclient,httpcore,commons-logging和joda-time)?它似乎很相似,否则无法解释的错误(给出非空参数,aws-sdk中的某些东西说它是空的)。