2

I'm trying to run an AWS Lambda using Docker image build by paketobuildpacks/builder using spring-native + spring-cloud-function-aws, but it's not handling incoming values, justs starts and returns an error, did I missed something?

Log output:

START RequestId: f7a451f1-f43b-4ba0-be3d-58526bfa0d10 Version: $LATEST
2021-06-30 00:20:58.229  INFO 8 --- [           main] o.s.nativex.NativeListener               : This application is bootstrapped with code generated with Spring AOT

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.5.1)

2021-06-30 00:20:58.251  INFO 8 --- [           main] o.s.boot.SpringApplication               : Starting application using Java 11.0.11 on 169.254.41.117 with PID 8 (started by sbx_user1051 in /workspace)
2021-06-30 00:20:58.251  INFO 8 --- [           main] o.s.boot.SpringApplication               : No active profile set, falling back to default profiles: default
2021-06-30 00:20:58.551  INFO 8 --- [           main] o.s.boot.SpringApplication               : Started application in 0.42 seconds (JVM running for 0.421)
END RequestId: f7a451f1-f43b-4ba0-be3d-58526bfa0d10
REPORT RequestId: f7a451f1-f43b-4ba0-be3d-58526bfa0d10  Duration: 840.41 ms Billed Duration: 841 ms Memory Size: 128 MB Max Memory Used: 29 MB  
RequestId: f7a451f1-f43b-4ba0-be3d-58526bfa0d10 Error: Runtime exited without providing a reason
Runtime.ExitError

Find my configs below:

Gradle Plugins:

kotlin("jvm")
kotlin("plugin.spring")
id("io.spring.dependency-management")
id("org.springframework.boot")
id("org.springframework.experimental.aot")
id("org.graalvm.buildtools.native")

Dependencies:

implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.springframework.cloud:spring-cloud-function-adapter-aws")
implementation("com.amazonaws:aws-lambda-java-events:2.0.2")
implementation("com.amazonaws:aws-lambda-java-core:1.1.0")

GraalVM plugin config:

tasks.withType<BootBuildImage> {
    builder = "paketobuildpacks/builder:tiny"
    environment = mapOf("BP_NATIVE_IMAGE" to "true")
}

App sources:

@SpringBootApplication
class LinkGeneratorApplication: ApplicationContextInitializer<GenericApplicationContext>  {
    override fun initialize(applicationContext: GenericApplicationContext) {
        applicationContext.registerBean(
            "function",
            FunctionRegistration::class.java,
            {
                FunctionRegistration(Function<Input, Result> { Result("Here") })
                    .type(
                        FunctionType
                            .from(Input::class.java)
                            .to(Result::class.java)
                            .type
                    )
            }
        )
    }

}

data class Input(val sellerId: String, val ownerId: String, val market: String)
data class Result(val message: String)

fun main(args: Array<String>) {
    runApplication<LinkGeneratorApplication>(*args)
}
Vladlen Gladis
  • 1,699
  • 5
  • 19
  • 41
  • I didn't find a way to make it work, but I switched to custom runtime backed by al2 os. you can find more details how to build and how it works here: https://gvart.dev/post/2023/02/native_spring_boot_aws_lambda/ – Vladlen Gladis Apr 11 '23 at 09:45

0 Answers0