AWS SAM CLI java8 runtime is not supported
Asked Answered
G

2

7

I'm trying to build a Lambda application using AWS SAM CLI command:

sam build --template C:/MyProject/template.yaml --build-dir C:/MyProject/.aws-sam/build

but I'm getting this error:

Build Failed

Error: 'java8' runtime is not supported

This is my template.yaml:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  AWS Serverless Application
  Sample SAM Template for AWS Serverless Application
Globals:
  Function:
      Timeout: 20
Resources:
  HelloWorldFunction:
      Type: AWS::Serverless::Function
      Properties:
          CodeUri: target/HelloWorld-1.0.jar
          Handler: helloworld.App::handleRequest
          Runtime: java8
          Environment: 
              Variables:
                  PARAM1: VALUE
          Events:
              HelloWorld:
                  Type: Api
                  Properties:
                      Path: /hello
                      Method: get

It's an example project made in Intellij using AWS Toolkit plugin, I have installed SAM CLI version 0.9.0 and jdk1.8.0_191 (I've tried different versions but it didn't work), at the project's GitHub I can see that java 8 is supported:

[ ] Supported AWS Lambda Runtimes
    [x] java8

Why am I getting this error?

Galvanotropism answered 17/12, 2018 at 12:15 Comment(2)
Got the same error. Were you able to figure this out?Perfection
Still no progress, for now I have to test everything in AWS without local testing.Galvanotropism
E
2

Seems like the build option doesn't support the java8 runtime

When I run sam build --help the result is: enter image description here which implies that it only works for python

Ebeneser answered 17/1, 2019 at 16:41 Comment(2)
That's correct, Java 8 support for build is still under development: github.com/awslabs/aws-sam-cli/issues/880Galvanotropism
This is not true anymore.Resistor
T
0

In my case,

Previously, I had given like below,

CodeUri: hello-world.jar

I have changed it to

CodeUri: ./hello-world

where hello-world is my java project's source directory.

Tinishatinker answered 16/7, 2021 at 3:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.