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

FunctionClient not compatible with GraalVM when invoking lambda functions #2065

Open
sh1bz opened this issue Feb 27, 2024 · 2 comments
Open
Assignees

Comments

@sh1bz
Copy link

sh1bz commented Feb 27, 2024

Expected Behavior

implementation("io.micronaut.aws:micronaut-function-client-aws")

@FunctionClient
interface LambdaClient {
@nAmed("checkout")
fun checkout(request: FunctionRequest): FunctionResponse
}

Invoking this method works when building using Java 21 ShadowJar and invoking it from another lambda.

Actual Behaviour

When deploying with buildNativeLambda for GraalVM Custom Runtime its throwing an exception:

context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2312)
at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3114)
at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:3016)
at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2977)
at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2751)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1750)
at io.micronaut.context.AbstractBeanResolutionContext.getBean(AbstractBeanResolutionContext.java:89)
at io.micronaut.context.AbstractInitializableBeanDefinition.resolveBean(AbstractInitializableBeanDefinition.java:2165)
at io.micronaut.context.AbstractInitializableBeanDefinition.getBeanForConstructorArgument(AbstractInitializableBeanDefinition.java:1328)
at io.micronaut.function.client.aws.$AWSLambdaFunctionExecutor$Definition.instantiate(Unknown Source)
at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2330)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2300)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2312)
at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3114)
at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:3016)
at io.micronaut.context.DefaultBeanContext.initializeEagerBean(DefaultBeanContext.java:2697)
at io.micronaut.context.DefaultBeanContext.initializeContext(DefaultBeanContext.java:1995)
... 16 more
Caused by: java.lang.ExceptionInInitializerError
at com.amazonaws.util.VersionInfoUtils.userAgent(VersionInfoUtils.java:142)
at com.amazonaws.util.VersionInfoUtils.initializeUserAgent(VersionInfoUtils.java:137)
at com.amazonaws.util.VersionInfoUtils.getUserAgent(VersionInfoUtils.java:100)
at com.amazonaws.ClientConfiguration.(ClientConfiguration.java:80)
at io.micronaut.aws.sdk.v1.AWSClientConfiguration.(AWSClientConfiguration.java:36)
at io.micronaut.aws.sdk.v1.$AWSClientConfiguration$Definition.instantiate(Unknown Source)
at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2330)
... 73 more
Caused by: java.lang.IllegalArgumentException
at com.amazonaws.internal.config.InternalConfig.loadfrom(InternalConfig.java:260)
at com.amazonaws.internal.config.InternalConfig.load(InternalConfig.java:274)
at com.amazonaws.internal.config.InternalConfig$Factory.(InternalConfig.java:347)
... 80 more
Request loop failed with: Bean definition [io.micronaut.function.client.aws.AWSLambdaFunctionExecutor] could not be loaded: Error instantiating bean of type [io.micronaut.function.client.aws.AWSLambdaConfiguration]
Path Taken: new AWSLambdaFunctionExecutor(AWSLambdaAsync asyncClient,ByteBufferFactory byteBufferFactory,JsonMediaTypeCodec jsonMediaTypeCodec,ExecutorService ioExecutor) --> new AWSLambdaFunctionExecutor([AWSLambdaAsync asyncClient],ByteBufferFactory byteBufferFactory,JsonMediaTypeCodec jsonMediaTypeCodec,ExecutorService ioExecutor) --> new AWSLambdaAsyncClientFactory([AWSLambdaConfiguration configuration]) --> new AWSLambdaConfiguration([AWSClientConfiguration clientConfiguration],Environment environment)
�[36m17:41:39.394�[0;39m �[1;30m[main]�[0;39m �[34mINFO �[0;39m �[35mi.m.s.ObjectMappers$ObjectMapperContext$1�[0;39m - Established active environments: [ec2, cloud, dev]

{
"errorMessage": "Bean definition [io.micronaut.function.client.aws.AWSLambdaFunctionExecutor] could not be loaded: Error instantiating bean of type [io.micronaut.function.client.aws.AWSLambdaConfiguration]\n\nPath Taken: new AWSLambdaFunctionExecutor(AWSLambdaAsync asyncClient,ByteBufferFactory byteBufferFactory,JsonMediaTypeCodec jsonMediaTypeCodec,ExecutorService ioExecutor) --> new AWSLambdaFunctionExecutor([AWSLambdaAsync asyncClient],ByteBufferFactory byteBufferFactory,JsonMediaTypeCodec jsonMediaTypeCodec,ExecutorService ioExecutor) --> new AWSLambdaAsyncClientFactory([AWSLambdaConfiguration configuration]) --> new AWSLambdaConfiguration([AWSClientConfiguration clientConfiguration],Environment environment)"
}

Steps To Reproduce

  1. Invoke Lambda ClientFunction from another lambda runnon on GraalVM

Environment Information

AWS Lambda -> x86 64 ( GraalVM ) Custom Runtime

Example Application

No response

Version

4.3.4

@sdelamo
Copy link
Contributor

sdelamo commented Feb 28, 2024

@msupic is this something you could investigate?

@sdelamo sdelamo removed this from 4.4.0 Release Apr 16, 2024
@sdelamo sdelamo self-assigned this Apr 16, 2024
@sh1bz
Copy link
Author

sh1bz commented Jul 31, 2024

@sdelamo I'm still struggling with this one. Would be great if we could include a fix as its a crucial part for AWS Lambda Native Support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Status: No status
Development

No branches or pull requests

2 participants