Soumya
Soumya

Reputation: 1913

Unable to upload file to S3 Bucket using aws-java-sdk

I have a spring boot application which uploads files to S3 bucket. I am receiving the following error whenever the application tries to upload a file. The stack trace is a huge one. So I am providing only a part of it.

java.lang.IllegalStateException: Socket not created by this factory
at org.apache.http.util.Asserts.check(Asserts.java:34) ~[httpcore-4.4.6.jar:4.4.6]
at org.apache.http.conn.ssl.SSLSocketFactory.isSecure(SSLSocketFactory.java:435) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:186) ~[httpclient-4.5.3.jar:4.5.3]

I am using the following dependency

    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk</artifactId>
        <version>1.11.123</version>
    </dependency>

I have even tried with

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.1.RELEASE</version>
    </parent>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-aws</artifactId>
    </dependency>
    <!--<dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-aws-context</artifactId>
    </dependency>

But sill getting the same type of error

I have tried using both TransferManager as well as putObject() method from AmazonS3 but with same error.

The application was running well a few days back and the error has started to come only very recently.

Upvotes: 0

Views: 1704

Answers (2)

Senzo Malinga
Senzo Malinga

Reputation: 132

I had the same issue on v1.10.12 of the SDK, I switched to v1.11.136 and that resolved my issue, add the code below, to your pom file

<!-- AWS S3 Dependencies-->
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk</artifactId>
        <version>1.11.136</version>
    </dependency>
<!-- End of AWS S3 Dependencies -->

Upvotes: 2

kiiadi
kiiadi

Reputation: 401

It would be useful to post more of the stack-trace so we can see at what point in the SDK lifecycle the exception is being generated (the stack-trace above only shows the apache classes). Can you also show how you're configuring the S3 client?

Are you configuring a custom SocketFactory? The check in question is looking to see if the Socket that the SocketFactory created is in fact an SSLSocket if not - that's where it bombs - you can see that from the Apache code here.

Upvotes: 0

Related Questions