java连接ceph报错

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

写了个java连接ceph进行对象存储的demo,结果报如下的错:

Exception in thread "main" com.amazonaws.services.s3.model.AmazonS3Exception: null (Service: Amazon S3; Status Code: 400; Error Code: InvalidArgument; Request ID: null), S3 Extended Request ID: null
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1529)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1167)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:948)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:661)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:635)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:618)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$300(AmazonHttpClient.java:586)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:573)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:445)
    at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4039)
    at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3976)
    at com.amazonaws.services.s3.AmazonS3Client.listObjects(AmazonS3Client.java:776)
    at com.amazonaws.services.s3.AmazonS3Client.listObjects(AmazonS3Client.java:748)

 

 

花了好一会功夫,找到原因:com.amazonaws的依赖包是最新版,向下支持不好


    com.amazonaws
    aws-java-sdk-s3
    1.11.39

 

解决办法:更改maven依赖如下即可,将version改设为一个较老的版本:


    com.amazonaws
    aws-java-sdk-s3
    1.10.69

转载于:https://my.oschina.net/u/2604795/blog/754484

你可能感兴趣的:(java连接ceph报错)