Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quarkus-amazon-lambda-rest doesn't support Java 17 ? #39038

Closed
nicolasduminil opened this issue Feb 27, 2024 · 5 comments
Closed

quarkus-amazon-lambda-rest doesn't support Java 17 ? #39038

nicolasduminil opened this issue Feb 27, 2024 · 5 comments
Labels
area/amazon-lambda kind/bug Something isn't working

Comments

@nicolasduminil
Copy link

Describe the bug

I'm using Quarkus 3.7.4 with the quarkus-amazon-lambda-rest extension. The build generates the following sam.jvm.yaml file in the target directory:

  AWSTemplateFormatVersion: '2010-09-09'
  Transform: AWS::Serverless-2016-10-31
  Description: AWS Serverless Quarkus HTTP - rest-gateway-api
  Globals:
    Api:
      EndpointConfiguration: REGIONAL
      BinaryMediaTypes:
        - "*/*"

  Resources:
    RestGatewayApi:
      Type: AWS::Serverless::Function
      Properties:
        Handler: io.quarkus.amazon.lambda.runtime.QuarkusStreamHandler::handleRequest
        Runtime: java11
        CodeUri: function.zip
        MemorySize: 512
        Policies: AWSLambdaBasicExecutionRole
        Timeout: 15
        Events:
          GetResource:
            Type: Api
            Properties:
              Path: /{proxy+}
              Method: any

  Outputs:
    RestGatewayApiApi:
      Description: URL for application
      Value: !Sub 'https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/'
      Export:
        Name: RestGatewayApiApi

The default runtime is, for some reason, Java 11. I'm modifying it to be Java 17 and I run the floowing command:

sam local start-api -t target/sam.jvm.yaml

Then running my integration tests I get the following:

Mounting RestGatewayApi at http://127.0.0.1:3000/{proxy+} [DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT]
You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. If you used sam build before running local commands, you will need to re-run sam build for the changes to be picked up. You only need to restart SAM CLI if you update your AWS SAM template
2024-02-27 19:37:16  * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
Invoking io.quarkus.amazon.lambda.runtime.QuarkusStreamHandler::handleRequest (java17)
Decompressing /home/nicolas/rest-gateway/rest-gateway-api/target/function.zip
Exception on /hello [GET]
Traceback (most recent call last):
  File "flask/app.py", line 2073, in wsgi_app
  File "flask/app.py", line 1518, in full_dispatch_request
  File "flask/app.py", line 1516, in full_dispatch_request
  File "flask/app.py", line 1502, in dispatch_request
  File "samcli/local/apigw/local_apigw_service.py", line 361, in _request_handler
  File "samcli/commands/local/lib/local_lambda.py", line 144, in invoke
  File "samcli/lib/telemetry/metric.py", line 277, in wrapped_func
  File "samcli/local/lambdafn/runtime.py", line 177, in invoke
  File "samcli/local/lambdafn/runtime.py", line 88, in create
  File "samcli/local/docker/lambda_container.py", line 91, in __init__
ValueError: Unsupported Lambda runtime java17
2024-02-27 19:37:53 127.0.0.1 - - [27/Feb/2024 19:37:53] "GET /hello HTTP/1.1" 502 -

Expected behavior

I expect that the integration tests run successfully.

Actual behavior

The mention exception is raised.

How to Reproduce?

Don't have a reproducer

Output of uname -a or ver

Linux nicolas-XPS-13-9360 6.5.0-21-generic #21~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Feb 9 13:32:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

java version "17.0.6" 2023-01-17 LTS Java(TM) SE Runtime Environment (build 17.0.6+9-LTS-190) Java HotSpot(TM) 64-Bit Server VM (build 17.0.6+9-LTS-190, mixed mode, sharing)

Quarkus version or git rev

3.7.4

Build tool (ie. output of mvnw --version or gradlew --version)

Maven home: /opt/apache-maven-3.9.4 Java version: 17.0.6, vendor: Oracle Corporation, runtime: /usr/lib/jvm/jdk-17 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "6.5.0-21-generic", arch: "amd64", family: "unix"

Additional information

The following command:

$ curl http://localhost:3000/hello

raises exactly the same exception.

@nicolasduminil nicolasduminil added the kind/bug Something isn't working label Feb 27, 2024
Copy link

quarkus-bot bot commented Feb 27, 2024

/cc @matejvasek (amazon-lambda), @patriot1burke (amazon-lambda)

@gsmet
Copy link
Member

gsmet commented Feb 27, 2024

We should definitely adjust the default runtime but we need to find a working value.

From what I can see, java17 should work: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

@gsmet
Copy link
Member

gsmet commented Feb 27, 2024

The descriptor might need some other changes but I have no experience with lambdas so can't really help.

@nicolasduminil
Copy link
Author

The file sam.jvm.yaml is quite simple an, besides the Runtime property, that I adjusted, there is nothing else to be modified. It defines the handler class, the functions.zip URI, memory size, security roles, timeouts, etc. None of these cannot impact the supported Java version.
What seems to happen is that the content of functions.zip is compiled with Java 11 insted of Java 17 and this is done by the quarkus-amazon-lambda-rest extension. Are there any properties that can be used to configure the Java version ?

@nicolasduminil
Copy link
Author

Using the last release of SAM CLI (1.110.0) fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/amazon-lambda kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants