Welcome! Please see the About page for a little more info on how this works.

0 votes
in Libs by

I'm attempting to retrieve a file from S3 from within an AWS Lambda using Congitect's aws-api library with a Java 8 runtime, but I'm consistently having problems:

(def s3 (aws/client {:api :s3}))

(defn open-file []
  (aws/invoke s3 {:op :GetObject :request {:Bucket "test-bucket" :Key "filename.txt"}}))

When calling open-file I get the following error:

{
  ":cognitect.anomalies/category": {
    "sym": {
      "name": "fault",
      "namespace": "cognitect.anomalies"
    },
    "name": "fault",
    "namespace": "cognitect.anomalies"
  },
  ":cognitect.anomalies/message": "java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;",
  ":cognitect.http-client/throwable": {
    "stackTrace": [
      {
        "methodName": "invokeStatic",
        "fileName": "http_client.clj",
        "lineNumber": 37,
        "className": "cognitect.http_client$empty_bbuf",
        "nativeMethod": false
      }
   ...

Is this a problem with my code? It seems to work when not in a Lambda.

1 Answer

+1 vote
by
selected by
 
Best answer

I have seen this error before (not in this context) and I dimly recall it to be something with changes in the JDK making something reflective, something like that. What JDK version is being used in the Lambda?

by
I tracked down one note about it - occurred when AOT compiling something on Java 11, then running on Java 8. Any chance that sounds applicable?
by
AWS only supports Java 8 and I compiled the code using JDK 8.
by
It is working now. It turns out that the code was fine, but I was using `jenv` in `fish` shell which wasn't fully setup, so I thought I was compiling with JRE 8, but I was actually using JRE 11.
by
Can you check one of the class files?

    javap -verbose <path/to/the.class> | grep major

Major version 52 is Java 8, 55 is Java 11
...