Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoSuchMethodError: com.amazonaws.services.s3.model.S3ObjectInputStream.readAllBytes()

I am working on a spring boot application which polls S3 bucket periodically using spring aws integration and processes the polled object from S3. While trying to read the processed object from another S3 bucket, i get the exception

java.lang.NoSuchMethodError: com.amazonaws.services.s3.model.S3ObjectInputStream.readAllBytes()[B
    at com.app.controller.AppController.viewImage(AppController.java:79) ~[classes!/:0.0.1-SNAPSHOT]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_191]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_191]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_191]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) ~[spring-web-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) ~[spring-web-5.0.3.RELEASE.jar!/:5.0.3.RELEASE]

It happens only in ec2 instances when i deploy as java application but does not occur in my local. Thinking that this might have been because of a class loading conflict with jars in amazon-linux ami, I tried deploying in ubuntu instance but the error repeats.

Just a snippet of my pom.xml which are relevant

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

        <!-- https://mvnrepository.com/artifact/org.springframework.integration/spring-integration-aws -->
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-aws</artifactId>
            <version>2.0.0.RELEASE</version>
        </dependency>

Can someone help me fix this issue ? Also please let me know if any other detail is needed apart from the ones mentioned

like image 400
Aarish Ramesh Avatar asked Feb 24 '26 14:02

Aarish Ramesh


1 Answers

realAllBytes is a method of a parent class InputStream. This method has been added to InputStream since Java 9. You are probably using a lower jdk version at runtime

like image 154
Dzmitry Bahdanovich Avatar answered Feb 26 '26 04:02

Dzmitry Bahdanovich