AWS Java SDK 2.15.73 (Current latest version). Java 1.8.222 Operating system IBM AIX 7.1
Developing an application that uploads a file to S3 bucket.
In Maven pom file:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.15.73</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>apache-client</artifactId>
<version>2.0.0-preview-10</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>http-client-spi</artifactId>
<version>2.0.0-preview-10</version>
</dependency>
</dependencies>
Beginning of Stacktrace:
Exception in sendFileToAWSNoAuth=Unable to marshall request to JSON: baseUri must not be null. software.amazon.awssdk.core.exception.SdkClientException: Unable to marshall request to JSON: baseUri must not be null. at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:98) at software.amazon.awssdk.services.s3.transform.PutObjectRequestMarshaller.marshall(PutObjectRequestMarshaller.java:53) at software.amazon.awssdk.services.s3.transform.PutObjectRequestMarshaller.marshall(PutObjectRequestMarshaller.java:31) at software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller.marshall(StreamingRequestMarshaller.java:48)
Java code:
Authentication is needed and execution thru proxy server.
String endPointURL = appParms.getProxyServer() + ":" + appParms.getProxyServerPort();
URI endPointUri = new URI(endPointURL);
ProxyConfiguration proxyConfig = ProxyConfiguration.builder() .endpoint(endPointUri) .build();
SdkHttpClient httpClient = ApacheSdkHttpClientFactory.builder() .proxyConfiguration(proxyConfig) .build() .createHttpClient();
ProfileCredentialsProvider credentialsProfile = ProfileCredentialsProvider.builder().profileName(appParms.getProfileName()).build();
Region region = Region.EU_CENTRAL_1; S3Client s3NonEncryption = S3Client.builder() .credentialsProvider(credentialsProfile) .region(region) .endpointOverride(endPointUri) .httpClient(httpClient) .build();
String folderKey = appParms.getBucketFolder() + "/" + appParms.getFileName();
File aFile = new File(appParms.getFilePath() + "/" + appParms.getFileName());
PutObjectRequest putOb = PutObjectRequest.builder() .bucket(appParms.getBucketNameSSE()) .key(folderKey) .build();
PutObjectResponse response = s3NonEncryption.putObject(putOb, aFile.toPath());
Exception occurs in this last line (s3NonEncryption.putObject)