1

I am trying to create a bucket with ceph and s3 library and get the below exception 405. Any pointers to resolve this issue?

com.amazonaws.services.s3.model.AmazonS3Exception: null (Service: Amazon S3; Status Code: 405; Error Code: MethodNotAllowed; Request ID: tx00000000000000000000a-005d37c963-1009-

Code:

        BasicAWSCredentials credentials = new BasicAWSCredentials("", "");
        ClientConfiguration clientConfig = new ClientConfiguration();
        clientConfig.setProtocol(Protocol.HTTP);

        AmazonS3 conn = new AmazonS3Client(credentials, clientConfig);
        conn.setEndpoint("localhost:8080");
        Bucket bucket = conn.createBucket("my-new-bucket");
Rob
  • 14,746
  • 28
  • 47
  • 65
Minisha
  • 2,117
  • 2
  • 25
  • 56
  • My setup is same as whatever mentioned in this video: https://www.youtube.com/watch?v=ZOD8IvxGNq0&t=6s – Minisha Jul 27 '19 at 02:11

2 Answers2

2

Try to add below code

conn.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(true));
Miguel Ruivo
  • 16,035
  • 7
  • 57
  • 87
iliul
  • 71
  • 6
  • 1
    I also struggled with 405 error when creating a bucket. The same code that worked previously on an older version of Ceph did not work on a newer Ceph anymore. I had to do S3Client.builder()... .forcePathStyle(true) .build(); to get it to work. Seems the newer version of Ceph requires path style access. Your answer put me on the right track, thank you! – Christoph Mar 14 '23 at 12:39
0

I got stuck for ages on MethodNotAllowed trying to create a ceph bucket.

Firstly I'd note that you should be able to use the s3cmd command line tool to create a bucket with the same user (or you should be able to see the same MethodNotAllowed response) to verify whether it's a problem with your java code.

For me the answer turn out to be this: You're not allowed to name your bucket "documents"! (not sure what other reserved words there are)

Harry Wood
  • 2,220
  • 2
  • 24
  • 46