I am facing this error in AWS lambda, We have a script execution framework on the server side, and I want to execute javascript using Quarkus Native code(this seems like best-concerning performance. If there are other solutions that provide similar performance, I am open to it.). I am getting the below error while executing the this code.
Engine engine = Engine.newBuilder()
.option("engine.WarnInterpreterOnly", "false")
.build();
Context ctx = Context.newBuilder("js").engine(engine).build();
ctx.getBindings("js").putMember(inputCode.getInputName(), inputCode.getInputParam());
Object js = ctx.eval("js", inputCode.getCode()).as(Object.class);
The following code results in the below error.
No language and polyglot implementation were found on the classpath. Make sure a language is added to the classpath (e.g., native-image --language:js)
These are my dependencies:
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-amazon-lambda-http</artifactId>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>native-image-base</artifactId>
<version>22.2.0</version>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js</artifactId>
<version>22.2.0</version>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js-scriptengine</artifactId>
<version>22.2.0</version>
</dependency>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-api</artifactId>
<version>22.2.0</version>
</dependency>
</dependencies>
As you can see, all the recommended dependencies are present in the pom. It works fine in normal JVM mode(local as well as AWS Lambda), but it fails in the AWS lambda environment for native image(local and in AWS remote )
I tried solution for this question, but it does not work for me in Quarkus.
Seems like the classload for Quarkus and Bukkit is different.
I found the answer; We need to add JS language as specified in this document. We need to check the available list of languages using
gu available
If the desired language is available, install it.
gu install js
Reference: https://www.graalvm.org/22.1/reference-manual/graalvm-updater/