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

Enhanced Dynmodb Compatibility Issue with graalvm and micronaut framework #1712

Open
amitmelbourne opened this issue May 11, 2023 · 5 comments

Comments

@amitmelbourne
Copy link

Expected Behavior

Micronaut should create object for Pojos annotaed with @Dynmodbbean

Actual Behaviour

BeanContext.createRegistration(DefaultBeanContext.java:3016)
at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:2918)
at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2879)
at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2800)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1617)
at io.micronaut.context.AbstractBeanResolutionContext.getBean(AbstractBeanResolutionContext.java:66)
at io.micronaut.context.AbstractInitializableBeanDefinition.resolveBean(AbstractInitializableBeanDefinition.java:2065)
at io.micronaut.context.AbstractInitializableBeanDefinition.getBeanForConstructorArgument(AbstractInitializableBeanDefinition.java:1297)
at com.ikano.pp.pricematrix.clients.$PnpPersistenceClient$Definition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2354)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2305)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2251)
at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3016)
at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:2918)
at io.micronaut.context.DefaultBeanContext.loadContextScopeBean(DefaultBeanContext.java:2746)
at io.micronaut.context.DefaultBeanContext.initializeContext(DefaultBeanContext.java:1915)
... 14 more
Caused by: java.lang.IllegalArgumentException: Class 'class com.xxxx.xx.xxxxxx.model.v1.Product' appears to have no default constructor thus cannot be used with the BeanTableSchema
at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.newObjectSupplierForClass(BeanTableSchema.java:377)
at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.createStaticTableSchema(BeanTableSchema.java:181)
at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.create(BeanTableSchema.java:137)
at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.create(BeanTableSchema.java:128)
at software.amazon.awssdk.enhanced.dynamodb.TableSchema.fromBean(TableSchema.java:83)
at com.ikano.pp.pricematrix.clients.PnpDynamoDbConfig.initWithTablePrefix(PnpDynamoDbConfig.java:52)
at com.ikano.pp.pricematrix.clients.PnpDynamoDbConfig.(PnpDynamoDbConfig.java:27)
at com.ikano.pp.pricematrix.clients.PnpDynamoDbClient.(PnpDynamoDbClient.java:23)
at com.ikano.pp.pricematrix.clients.$PnpDynamoDbClient$Definition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2354)
... 34 more
Caused by: java.lang.NoSuchMethodException: com.ikano.pp.pricematrix.model.v1.Product.()
at [email protected]/java.lang.Class.getConstructor0(DynamicHub.java:3349)
at [email protected]/java.lang.Class.getConstructor(DynamicHub.java:2151)
at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.newObjectSupplierForClass(BeanTableSchema.java:372)
... 43 more
Request loop failed with: Exception thrown instantiating MicronautLambdaRuntimeHandler
Invoking Function End
Invoking Function Start
�[36m07:08:28.445�[0;39m �[1;30m[main]�[0;39m �[34mINFO �[0;39m �[35mi.m.f.a.p.AbstractLambdaContainerHandler�[0;39m - Starting Lambda Container Handler
�[36m07:08:29.081�[0;39m �[1;30m[main]�[0;39m �[34mINFO �[0;39m �[35mi.m.context.env.DefaultEnvironment�[0;39m - Established active environments: [ec2, cloud, lambda, function]
START RequestId: 7adb2ee1-0879-4dbc-8971-b13869a76796 Version: $LATEST
2023-05-09T07:08:29.141Z 7adb2ee1-0879-4dbc-8971-b13869a76796 Task timed out after 3.05 seconds
END RequestId: 7adb2ee1-0879-4dbc-8971-b13869a76796
REPORT RequestId: 7adb2ee1-0879-4dbc-8971-b13869a76796 Duration: 3046.46 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 44 MB

Steps To Reproduce

No response

Environment Information

No response

Example Application

No response

Version

3.9.1

@amitmelbourne amitmelbourne changed the title Enhanced Dynmodb Compatibility Issue Enhanced Dynmodb Compatibility Issue with graalvm and micronaut framework May 11, 2023
@graemerocher graemerocher transferred this issue from micronaut-projects/micronaut-core May 11, 2023
@amitmelbourne
Copy link
Author

amitmelbourne commented May 11, 2023

I tried using @ReflectiveAccess on annotation on my pojo but i still got the issue mentioned on oracle/graal#3386.
I am not sure when this issue will be fixed?

I am using graalvm version 22.3.2 and trying to deploy native image build using micronaut framework, graalvm and enhanced dynmodb on aws lambda.

.getBean(DefaultBeanContext.java:1617)
at io.micronaut.context.AbstractBeanResolutionContext.getBean(AbstractBeanResolutionContext.java:66)
at io.micronaut.context.AbstractInitializableBeanDefinition.resolveBean(AbstractInitializableBeanDefinition.java:2065)
at io.micronaut.context.AbstractInitializableBeanDefinition.getBeanForConstructorArgument(AbstractInitializableBeanDefinition.java:1297)
at com.ikano.pp.pricematrix.clients.$PnpPersistenceClient$Definition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2354)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2305)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2251)
at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3016)
at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80)
at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:2918)
at io.micronaut.context.DefaultBeanContext.loadContextScopeBean(DefaultBeanContext.java:2746)
at io.micronaut.context.DefaultBeanContext.initializeContext(DefaultBeanContext.java:1915)
... 14 more
Caused by: java.lang.IllegalArgumentException: Failed to generate method handle.
at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.LambdaToMethodBridgeBuilder.build(LambdaToMethodBridgeBuilder.java:92)
at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.ObjectConstructor.create(ObjectConstructor.java:37)
at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.newObjectSupplierForClass(BeanTableSchema.java:382)
at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.createStaticTableSchema(BeanTableSchema.java:189)
at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.create(BeanTableSchema.java:145)
at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.lambda$create$0(BeanTableSchema.java:135)
at [email protected]/java.util.Map.computeIfAbsent(Map.java:1003)
at [email protected]/java.util.Collections$SynchronizedMap.computeIfAbsent(Collections.java:2682)
at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.create(BeanTableSchema.java:135)
at software.amazon.awssdk.enhanced.dynamodb.TableSchema.fromBean(TableSchema.java:86)
at com.ikano.pp.pricematrix.clients.PnpDynamoDbConfig.initWithTablePrefix(PnpDynamoDbConfig.java:52)
at com.ikano.pp.pricematrix.clients.PnpDynamoDbConfig.(PnpDynamoDbConfig.java:27)
at com.ikano.pp.pricematrix.clients.PnpDynamoDbClient.(PnpDynamoDbClient.java:23)
at com.ikano.pp.pricematrix.clients.$PnpDynamoDbClient$Definition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2354)
... 34 more
Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: Defining anonymous classes at runtime is not supported.
at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:89)
at [email protected]/jdk.internal.misc.Unsafe.defineAnonymousClass(Unsafe.java:146)
at [email protected]/java.lang.invoke.InnerClassLambdaMetafactory.spinInnerClass(InnerClassLambdaMetafactory.java:302)
at [email protected]/java.lang.invoke.InnerClassLambdaMetafactory.buildCallSite(InnerClassLambdaMetafactory.java:193)
at [email protected]/java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:329)
at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.LambdaToMethodBridgeBuilder.build(LambdaToMethodBridgeBuilder.java:83)
... 48 more
Request loop failed with: Exception thrown instantiating MicronautLambdaRuntimeHandler
Invoking Function End
Invoking Function Start
START RequestId: 7022019a-a04a-465e-bbc7-65caf822e415 Version: $LATEST
2023-05-11T11:07:18.778Z 7022019a-a04a-465e-bbc7-65caf822e415 Task timed out after 3.02 seconds

END RequestId: 7022019a-a04a-465e-bbc7-65caf822e415
REPORT RequestId: 7022019a-a04a-465e-bbc7-65caf822e415 Duration: 3024.90 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 49 MB

@sdelamo
Copy link
Contributor

sdelamo commented May 18, 2023

@amitmelbourne do you have a sample app?

@amitmelbourne
Copy link
Author

amitmelbourne commented May 19, 2023 via email

@amitmelbourne
Copy link
Author

Hi Team @graemerocher is there any update on the above issue.

@scprek
Copy link
Contributor

scprek commented Apr 30, 2024

I mentioned adding Enhanced dynamodb beans #1664. Not sure if our solution is the best either as I just found https://github.com/agorapulse/micronaut-aws-sdk

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

No branches or pull requests

3 participants