Anmol Jain
Anmol Jain

Reputation: 411

FileSystemNotFoundException in GraalVM Javascript Engine in Springboot Application

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 ?

Upvotes: 0

Views: 58

Answers (0)

Related Questions