title: AWS S3 Get object version returns Error Code: 500 Internal Server Error
body: <p>I've got the following error when retrieving the version of an object stored in my S3 running on Localstack (docker) : </p>
  
  <blockquote>
    <p>com.amazonaws.services.s3.model.AmazonS3Exception: Internal Server Error (Service: Amazon S3; Status Code: 500; Error Code: 500 Internal Server Error; Request ID: null), S3 Extended Request ID: null</p>
  </blockquote>
  
  <p>I've tested with versions 1.11.163, 1.11.359, 1.11.383 of aws-java-sdk.</p>
  
  <p>Listing and deleting the files works but I can't get the version using the SDK.</p>
  
  <p>The thing is that when using the cli I can list the objects' versions in my bucket.</p>
  
  <p>When listing the versions of the files in my bucket : </p>
  
  <blockquote>
    <p>aws --endpoint-url=<a href="http://localhost:4572" rel="nofollow noreferrer">http://localhost:4572</a> s3api list-object-versions --bucket my-bucket --prefix testFolder</p>
  </blockquote>
  
  <p>I get the following output : </p>
  
  <pre><code>{
  "Versions": [
      {
          "LastModified": "2018-08-10T08:52:06.193Z", 
          "VersionId": "0", 
          "ETag": "\"da9a0adf68f7fa4da720e10914283cc9\"", 
          "StorageClass": "STANDARD", 
          "Key": "testFolder/test.txt", 
          "Owner": {
              "DisplayName": "webfile", 
              "ID": "75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a"
          }, 
          "IsLatest": true, 
          "Size": 7366
      }, 
      {
          "LastModified": "2018-08-10T08:52:06.188Z", 
          "VersionId": "0", 
          "ETag": "\"5f22390dd70444e4f3ea347313442a6d\"", 
          "StorageClass": "STANDARD", 
          "Key": "testFolder/0001/test.txt", 
          "Owner": {
              "DisplayName": "webfile", 
              "ID": "75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a"
          }, 
          "IsLatest": true, 
          "Size": 2507
      }, 
      {
          "LastModified": "2018-08-10T08:52:06.191Z", 
          "VersionId": "0", 
          "ETag": "\"9001b739dd280ace7b6b7ae45377484a\"", 
          "StorageClass": "STANDARD", 
          "Key": "testFolder/0001/test-other.txt", 
          "Owner": {
              "DisplayName": "webfile", 
              "ID": "75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a"
          }, 
          "IsLatest": true, 
          "Size": 4589
      }, 
      {
          "LastModified": "2018-08-10T08:52:06.185Z", 
          "VersionId": "0", 
          "ETag": "\"4d32ffe9a1f7e272c78aa80e95fb9cf3\"", 
          "StorageClass": "STANDARD", 
          "Key": "testFolder/test-other.txt", 
          "Owner": {
              "DisplayName": "webfile", 
              "ID": "75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a"
          }, 
          "IsLatest": true, 
          "Size": 15549
      }
  ]
  }
  </code></pre>
  
  <p>Here is how I create my S3Configuration : </p>
  
  <pre><code>private static S3Configuration s3Configuration() {
      S3Configuration s3Configuration = new S3Configuration();
      s3Configuration.setBucket("my-bucket");
      return s3Configuration;
  }
  </code></pre>
  
  <p>Here is how I create my AmazonS3 client : </p>
  
  <pre><code>private static AmazonS3 amazonS3() {
      final AWSCredentials credentials = new BasicAWSCredentials("foobar","foobar");
      final EndpointConfiguration endpointConfiguration = new EndpointConfiguration("http://localhost:4572",DEFAULT_REGION.getName());
  
      AmazonS3ClientBuilder amazonS3ClientBuilder = AmazonS3ClientBuilder.standard()
              .withCredentials(new AWSStaticCredentialsProvider(credentials))
              .withEndpointConfiguration(endpointConfiguration)
              .withPathStyleAccessEnabled(true);
  
      return amazonS3ClientBuilder.build();
  }
  </code></pre>
  
  <p>The exception occurs whenever I try to list the versions of the files in my bucket using :</p>
  
  <pre><code>VersionListing versionListing = amazonS3.listVersions(new ListVersionsRequest().withBucketName(bucketName));
  </code></pre>
  
  <p>Or trying to get the version for a specific file : </p>
  
  <pre><code>VersionListing versionListing = amazonS3.listVersions(bucketName, objectKey);
  </code></pre>
  
  <p>Where objectKey is retrieve from an S3ObjectSummary.getKey()</p>
  
  <p>Any idea of what I am missing?</p>
  
  <p>Thanks for your help.</p>