Coder Social home page Coder Social logo

quarkus-amazon-alexa's Introduction

Quarkus Amazon Alexa

All Contributors

Version

Introduction

Quarkus Amazon Alexa is a Quarkus extension for the Amazon Alexa SDK.

The main purpose of this extension is to make the Amazon Alexa SDK work in a native executable built with GraalVM/Mandrel.

Compatibility

Quarkus Quarkus Amazon Alexa
2.x 1.x
3.x 2.x

Contributors โœจ

Thanks goes to these wonderful people (emoji key):


Timothy Power

๐Ÿ’ป ๐Ÿšง

Guillaume Smet

๐Ÿ’ป

timguy

๐Ÿ’ป

This project follows the all-contributors specification. Contributions of any kind welcome!

quarkus-amazon-alexa's People

Contributors

actions-user avatar allcontributors[bot] avatar aloubyansky avatar dependabot[bot] avatar famod avatar gastaldi avatar gsmet avatar oztimpower avatar slyngdk avatar stuartwdouglas avatar timguy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

gsmet timguy

quarkus-amazon-alexa's Issues

Native Image generation fails because of referenced aws-java-sdk-core using java.util.Random

Hi thanks for the plugin, but I get the following error when trying to build a native image:
gradlew build -x test -Dquarkus.package.type=native -Dquarkus.native.container-build=true -Dquarkus.native.additional-build-args="--initialize-at-run-time=com.amazonaws.retry.PredefinedBackoffStrategies --trace-object-instantiation=java.util.Random"

[1/7] Initializing...                                                                                   (11,1s @ 0,15GB)
 Version info: 'GraalVM 22.2.0 Java 17 CE'
 Java version info: '17.0.4+8-jvmci-22.2-b06'
 C compiler: gcc (redhat, x86_64, 8.5.0)
 ....
Fatal error: org.graalvm.compiler.debug.GraalError: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected.  Object has been initialized by the com.amazonaws.ClientConfiguration class initializer with a trace:
        at java.util.Random.<init>(Random.java:109)
        at com.amazonaws.retry.PredefinedBackoffStrategies$EqualJitterBackoffStrategy.<init>(PredefinedBackoffStrategies.java:82)
        at com.amazonaws.retry.PredefinedBackoffStrategies$SDKDefaultBackoffStrategy.<init>(PredefinedBackoffStrategies.java:138)
        at com.amazonaws.retry.PredefinedRetryPolicies.<clinit>(PredefinedRetryPolicies.java:89)
        at com.amazonaws.ClientConfiguration.<clinit>(ClientConfiguration.java:79)
. Try avoiding to initialize the class that caused initialization of the object. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisFuture.setException(AnalysisFuture.java:49)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:269)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisFuture.ensureDone(AnalysisFuture.java:63)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.lambda$postTask$9(ImageHeapScanner.java:611)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:193)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:177)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1395)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected.  Object has been initialized by the com.amazonaws.ClientConfiguration class initializer with a trace:
        at java.util.Random.<init>(Random.java:109)
        at com.amazonaws.retry.PredefinedBackoffStrategies$EqualJitterBackoffStrategy.<init>(PredefinedBackoffStrategies.java:82)
        at com.amazonaws.retry.PredefinedBackoffStrategies$SDKDefaultBackoffStrategy.<init>(PredefinedBackoffStrategies.java:138)
        at com.amazonaws.retry.PredefinedRetryPolicies.<clinit>(PredefinedRetryPolicies.java:89)
        at com.amazonaws.ClientConfiguration.<clinit>(ClientConfiguration.java:79)
. Try avoiding to initialize the class that caused initialization of the object. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.image.DisallowedImageHeapObjectFeature.error(DisallowedImageHeapObjectFeature.java:173)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.image.DisallowedImageHeapObjects.check(DisallowedImageHeapObjects.java:62)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.image.DisallowedImageHeapObjectFeature.replacer(DisallowedImageHeapObjectFeature.java:149)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisUniverse.replaceObject(AnalysisUniverse.java:583)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.replaceObject(AnalysisConstantReflectionProvider.java:257)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.interceptValue(AnalysisConstantReflectionProvider.java:228)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.heap.SVMImageHeapScanner.transformFieldValue(SVMImageHeapScanner.java:126)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.onFieldValueReachable(ImageHeapScanner.java:331)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.lambda$createImageHeapObject$3(ImageHeapScanner.java:272)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        ... 10 more

The reason is the java.util.Random used in com.amazonaws.retry.PredefinedBackoffStrategies and com.amazonaws.ClientConfiguration (aws-java-sdk-core-1.11.420.jar) which is fetched by io.quarkiverse.amazonalexa:quarkus-amazon-alexa:1.0.3

quarkusDevBaseRuntimeClasspathConfiguration
+--- io.quarkus.platform:quarkus-bom:2.12.1.Final
+--- io.quarkiverse.amazonalexa:quarkus-amazon-alexa:1.0.3
|    +--- io.quarkus:quarkus-apache-httpclient:2.10.0.Final -> 2.12.1.Final
|    |    +--- io.quarkus:quarkus-arc:2.12.1.Final (*)
|    |    +--- org.apache.httpcomponents:httpclient:4.5.13
|    |    |    +--- org.apache.httpcomponents:httpcore:4.4.13 -> 4.4.15
|    |    |    \--- commons-codec:commons-codec:1.11 -> 1.15
|    |    \--- org.jboss.logging:commons-logging-jboss-logging:1.0.0.Final
|    |         \--- org.jboss.logging:jboss-logging:3.3.1.Final -> 3.5.0.Final
|    +--- com.amazon.alexa:ask-sdk:2.43.7          Juni 22   -  2.44.0 Ende August
|    |    +--- com.amazon.alexa:ask-sdk-core:2.43.7
|    |    |    +--- com.amazon.alexa:ask-sdk-runtime:2.43.7
|    |    |    |    +--- com.fasterxml.jackson.core:jackson-core:2.12.6 -> 2.13.3 (*)
|    |    |    |    +--- com.fasterxml.jackson.core:jackson-databind:2.12.6.1 -> 2.13.3 (*)
|    |    |    |    +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.6 -> 2.13.3 (*)
|    |    |    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.12.6 -> 2.13.3 (*)
|    |    |    |    \--- org.slf4j:slf4j-api:1.7.32 -> 1.7.36
|    |    |    +--- com.amazon.alexa:ask-sdk-model:1.39.4
|    |    |    |    \--- com.amazon.alexa:ask-sdk-model-runtime:1.0.5
|    |    |    |         +--- com.fasterxml.jackson.core:jackson-annotations:2.10.4 -> 2.13.3 (*)
|    |    |    |         +--- com.fasterxml.jackson.core:jackson-databind:2.10.4 -> 2.13.3 (*)
|    |    |    |         \--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.4 -> 2.13.3 (*)
|    |    |    \--- org.slf4j:slf4j-api:1.7.10 -> 1.7.36
|    |    +--- com.amazon.alexa:ask-sdk-lambda-support:2.43.7
|    |    |    +--- com.amazon.alexa:ask-sdk-runtime:2.43.7 (*)
|    |    |    +--- com.amazonaws:aws-lambda-java-core:1.2.1
|    |    |    \--- commons-io:commons-io:2.7 -> 2.11.0
|    |    +--- com.amazon.alexa:ask-sdk-servlet-support:2.43.7
|    |    |    +--- com.amazon.alexa:ask-sdk-core:2.43.7 (*)
|    |    |    +--- commons-codec:commons-codec:1.6 -> 1.15
|    |    |    +--- commons-io:commons-io:2.7 -> 2.11.0
|    |    |    \--- org.slf4j:slf4j-api:1.7.10 -> 1.7.36
|    |    +--- com.amazon.alexa:ask-sdk-dynamodb-persistence-adapter:2.43.7
|    |    |    +--- com.amazon.alexa:ask-sdk-core:2.43.7 (*)
|    |    |    \--- com.amazonaws:aws-java-sdk-dynamodb:1.11.420		###################################
|    |    |         +--- com.amazonaws:aws-java-sdk-s3:1.11.420
|    |    |         |    +--- com.amazonaws:aws-java-sdk-kms:1.11.420
|    |    |         |    |    +--- com.amazonaws:aws-java-sdk-core:1.11.420             ###################################

What I tried

gradlew build -x test -Dquarkus.package.type=native -Dquarkus.native.container-build=true -Dquarkus.native.additional-build-args="--initialize-at-run-time=com.amazonaws.retry.PredefinedBackoffStrategies --initialize-at-run-time=com.amazonaws.ClientConfiguration --trace-object-instantiation=java.util.Random"
but got the same errors.

Question

  • how to get rid of the error? For sure it is somehow possible with command line
  • At longterm. Would it be possible to fix it in here? io.quarkiverse.amazonalexa:quarkus-amazon-alexa:1.0.3

Native Lambda Zip in AWS Lambda - Cannot create an instance of com.amazonaws.auth.AWS4Signer

I have a skill, wich I "quarkified" for faster runtime (just overwrite everything from the zip I got from https://code.quarkus.io/?b=GRADLE&e=io.quarkiverse.amazonalexa%3Aquarkus-amazon-alexa&extension-search=origin:platform%20alexa)

  • quarkus-amazon-alexa](io.quarkiverse.amazonalexa:quarkus-amazon-alexa:1.0.3
  • Version info: 'GraalVM 22.2.0 Java 17 CE', Java version info: '17.0.4+8-jvmci-22.2-b06', C compiler: gcc (redhat, x86_64, 8.5.0)
  • I created a native build and upload to AWS lambda
  • Runtime: Custom runtime
Following error:
by Quarkus 2.12.1.Final) started in 0.069s. 
2022-09-14 13:04:43,175 INFO  [io.quarkus] (main) Profile prod activated. 
2022-09-14 13:04:43,175 INFO  [io.quarkus] (main) Installed features: [amazon-alexa, amazon-lambda, cdi]
START RequestId: 49fd4fb6-c3b9-479f-b8bd-a06bb7eee3cc Version: $LATEST
2022-09-14 13:04:43,535 ERROR [io.qua.ama.lam.run.AbstractLambdaPollLoop] (Lambda Thread (NORMAL)) Failed to run lambda (NORMAL): java.lang.IllegalStateException: Cannot create an instance of com.amazonaws.auth.AWS4Signer
at com.amazonaws.auth.SignerFactory.createSigner(SignerFactory.java:172)
at com.amazonaws.auth.SignerFactory.createSigner(SignerFactory.java:126)
at com.amazonaws.auth.SignerFactory.lookupAndCreateSigner(SignerFactory.java:114)
at com.amazonaws.auth.SignerFactory.getSigner(SignerFactory.java:83)
at com.amazonaws.AmazonWebServiceClient.computeSignerByServiceRegion(AmazonWebServiceClient.java:399)
at com.amazonaws.AmazonWebServiceClient.computeSignerByURI(AmazonWebServiceClient.java:371)
at com.amazonaws.AmazonWebServiceClient.setEndpoint(AmazonWebServiceClient.java:264)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.init(AmazonDynamoDBClient.java:362)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.<init>(AmazonDynamoDBClient.java:335)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder.build(AmazonDynamoDBClientBuilder.java:109)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder.build(AmazonDynamoDBClientBuilder.java:30)
at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)
at com.amazon.ask.attributes.persistence.impl.DynamoDbPersistenceAdapter.<init>(DynamoDbPersistenceAdapter.java:114)
at com.amazon.ask.attributes.persistence.impl.DynamoDbPersistenceAdapter.<init>(DynamoDbPersistenceAdapter.java:46)
at com.amazon.ask.attributes.persistence.impl.DynamoDbPersistenceAdapter$Builder.build(DynamoDbPersistenceAdapter.java:350)
at com.amazon.ask.module.StandardSdkModule$Builder.build(StandardSdkModule.java:206)
at com.amazon.ask.builder.StandardSkillBuilder.getConfigBuilder(StandardSkillBuilder.java:100)
at com.amazon.ask.builder.StandardSkillBuilder.build(StandardSkillBuilder.java:109)
at github.timguy.theskill.StreamHandler.getSkill(StreamHandler.java:86)
at github.timguy.theskill.StreamHandler.<init>(StreamHandler.java:90)
at github.timguy.theskill.StreamHandler_Bean.create(Unknown Source)
at github.timguy.theskill.StreamHandler_Bean.get(Unknown Source)
at github.timguy.theskill.StreamHandler_Bean.get(Unknown Source)

at io.quarkus.arc.impl.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:468)
at io.quarkus.arc.impl.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:481)
at io.quarkus.arc.impl.ArcContainerImpl$1.get(ArcContainerImpl.java:285)
at io.quarkus.arc.impl.ArcContainerImpl$1.get(ArcContainerImpl.java:282)
at io.quarkus.arc.runtime.BeanContainerImpl$1.create(BeanContainerImpl.java:36)
at io.quarkus.arc.runtime.BeanContainer.instance(BeanContainer.java:19)
at io.quarkus.amazon.lambda.runtime.AmazonLambdaRecorder$1.processRequest(AmazonLambdaRecorder.java:191)
at io.quarkus.amazon.lambda.runtime.AbstractLambdaPollLoop$1.run(AbstractLambdaPollLoop.java:117)
at java.lang.Thread.run(Thread.java:833)
at com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:705)
at com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:202)
Caused by: java.lang.InstantiationException: com.amazonaws.auth.AWS4Signer
at java.lang.Class.newInstance(DynamicHub.java:639)
at com.amazonaws.auth.SignerFactory.createSigner(SignerFactory.java:169)
... 33 more
Caused by: java.lang.NoSuchMethodException: com.amazonaws.auth.AWS4Signer.<init>()
at java.lang.Class.getConstructor0(DynamicHub.java:3585)
at java.lang.Class.newInstance(DynamicHub.java:626)
... 34 more
END RequestId: 49fd4fb6-c3b9-479f-b8bd-a06bb7eee3cc
REPORT RequestId: 49fd4fb6-c3b9-479f-b8bd-a06bb7eee3cc	Duration: 636.16 ms	Billed Duration: 919 ms	Memory Size: 128 MB	Max Memory Used: 70 MB	Init Duration: 282.58 ms	

The AmazonDynamoDBClient is fetched because of my StreamHandler class and configuration withTableName("theskill_userData").

public class StreamHandler extends SkillStreamHandler {

	private static Skill getSkill() {^        
		return Skills.standard()
                .addRequestHandlers(
                		new LaunchRequestHandler(),
						...
                .addRequestInterceptors(new LogInterceptor(),new NewSessionRequestInterceptor())
                .withTableName("theskill_userData")
                .withAutoCreateTable(true) 
                .withSkillId(appId)
                .build();

Both classes:
com.amazonaws.auth.SignerFactory.createSigner(SignerFactory.java:172)
com.amazonaws.auth.AWS4Signer
are from aws-java-sdk-core-1.11.420

SignerFactory uses Class.newInstance which is marked as deprecated:

This method propagates any exception thrown by the
* nullary constructor, including a checked exception. Use of
* this method effectively bypasses the compile-time exception
* checking that would otherwise be performed by the compiler.

Could this give a hint how to fix this with quarkus/native?
Maybe this could help as well: oracle/graal#1367 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.