0

I created a springboot project and added GraalVM dependency in pom.xml to execute Javascript Code in my Spingboot Project.

        <dependency>
            <groupId>org.graalvm.js</groupId>
            <artifactId>js</artifactId>
            <version>1.0.0-rc10</version>
        </dependency>

        <dependency>
            <groupId>org.graalvm.js</groupId>
            <artifactId>js-scriptengine</artifactId>
            <version>1.0.0-rc10</version>
        </dependency>

        <dependency>
            <groupId>org.graalvm.truffle</groupId>
            <artifactId>truffle-api</artifactId>
            <version>1.0.0-rc10</version>
        </dependency>

I wrote the code to execute javascript code in my app.

 public String transformJson(String transformationFunction, String payload) {

        Context context = Context.create();

        if (transformationFunction == null || transformationFunction.isEmpty()) 
            transformationFunction = "(function transform(payload) {\n" + "   return payload; \n" + "})";
        else
            transformationFunction = "(" + transformationFunction + ")";

        Value eval = context.eval("js", transformationFunction);
        return eval.execute(payload).asString();
    }

It is working fine in my local system but in deployed version on AWS, it is giving FileSystemNotFoundException Exception.

java.nio.file.FileSystemNotFoundException: null
        at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:156)
        at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:142)
        at java.base/java.nio.file.Path.of(Path.java:208)
        at java.base/java.nio.file.Paths.get(Paths.java:98)
        at com.oracle.truffle.polyglot.LanguageCache.collectLanguages(LanguageCache.java:284)
        at com.oracle.truffle.polyglot.LanguageCache.createLanguages(LanguageCache.java:211)
        at com.oracle.truffle.polyglot.LanguageCache.languages(LanguageCache.java:201)
        at com.oracle.truffle.polyglot.PolyglotEngineImpl.initializeLanguages(PolyglotEngineImpl.java:486)
        at com.oracle.truffle.polyglot.PolyglotEngineImpl.<init>(PolyglotEngineImpl.java:174)
        at com.oracle.truffle.polyglot.PolyglotEngineImpl.<init>(PolyglotEngineImpl.java:158)
        at com.oracle.truffle.polyglot.PolyglotImpl.buildEngine(PolyglotImpl.java:197)
        at org.graalvm.polyglot.Engine$Builder.build(Engine.java:488)
        at org.graalvm.polyglot.Context$Builder.build(Context.java:1085)
        at org.graalvm.polyglot.Context.create(Context.java:663)
        at com.infy.supplier.erp.service.impl.JavascriptEngineServiceImpl.transformJson(JavascriptEngineServiceImpl.java:17)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
        at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:64)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:751)
        at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:89)
        at com.infy.supplier.erp.aop.logging.LoggingAspect.logAround(LoggingAspect.java:105)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)

On doing some research on internet, I found that it is unable to locate the language configuration file and we need to point it out in system's environment variables explicitly. But I did not do this in my local system, yet it is working fine. And I could not find any specific language configuration file of Graal VM.

How can I resolve this error ?

4
  • that version 1.0.0-rc10 looks wrong, latest version is 24.0.1 please check. Commented May 2, 2024 at 22:20
  • Thanks for the correction. But I don't think it's the version problem. I updated the version but still facing the same issue. Commented May 3, 2024 at 4:50
  • FileSystemNotFoundException means some file is missing, can you share a small reproducer ? Commented May 3, 2024 at 7:01
  • On doing some research on google, I found that the language configuration file is missing. But I did not explicitly added any file in my local system and it is working fine just with maven dependencies. Commented May 4, 2024 at 6:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.