-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Cannot run polyglot code with Spring Boot executable JAR and Java 21 #7625
Comments
I can relate the exact same issue on Windows java.lang.NullPointerException: null
at java.base/java.util.Objects.requireNonNull(Objects.java:233) ~[na:na]
at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:215) ~[na:na]
at java.base/java.nio.file.Path.of(Path.java:148) ~[na:na]
at org.graalvm.polyglot.Engine$ClassPathIsolation.collectClassPathJars(Engine.java:1988) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$ClassPathIsolation.createIsolatedTruffleModule(Engine.java:1783) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$ClassPathIsolation.createIsolatedTruffle(Engine.java:1723) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$1.searchServiceLoader(Engine.java:1682) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$1.run(Engine.java:1668) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$1.run(Engine.java:1663) ~[polyglot-23.1.0.jar!/:na]
at java.base/java.security.AccessController.doPrivileged(AccessController.java:319) ~[na:na]
at org.graalvm.polyglot.Engine.initEngineImpl(Engine.java:1663) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$ImplHolder.<clinit>(Engine.java:186) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine.getImpl(Engine.java:438) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$Builder.build(Engine.java:736) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Context$Builder.build(Context.java:1925) ~[polyglot-23.1.0.jar!/:na] I am using:
Code snippet: I confirm that the issue occurs when running the project as an executable jar: |
It seems, the modules are missing, if you start your application with Download latest graaljs-community-jvm for your platform from https://github.com/oracle/graaljs/releases/ and $JDK should link to your graalvm root folder and $GRAALVM_JARS should link to your modules folder Important: Make sure you have downloaded the graaljs standalone package. If not, the modules folder doesn't exists in other non polyglot graalvm distributions.
|
Same issue with the configuration from above lgr@PCLoic:/mnt/c/Users/LoicG/Downloads/graaljs-community-jvm-23.1.1-linux-amd64.tar/js-java-standalone-svm-java21/graaljs-community-23.1.1-linux-amd64$ export JDK=$PWD
lgr@PCLoic:/mnt/c/Users/LoicG/Downloads/graaljs-community-jvm-23.1.1-linux-amd64.tar/js-java-standalone-svm-java21/graaljs-community-23.1.1-linux-amd64$ export GRAALVM_JARS=$PWD/modules
lgr@PCLoic:/mnt/c/Users/LoicG/Downloads/graaljs-community-jvm-23.1.1-linux-amd64.tar/js-java-standalone-svm-java21/graaljs-community-23.1.1-linux-amd64$ $JDK/jvm/bin/java --module-path=$GRAALVM_JARS/truffle-runtime.jar:$GRAALVM_JARS/jniutils.jar:$GRAALVM_JARS/polyglot.jar:$GRAALVM_JARS/launcher-common.jar:$GRAALVM_JARS/graaljs-launcher.jar:$GRAALVM_JARS/graaljs.jar:$GRAALVM_JARS/truffle-api.jar:$GRAALVM_JARS/graal-sdk.jar:$GRAALVM_JARS/tregex.jar:$GRAALVM_JARS/truffle-icu4j.jar -jar ../demo-0.0.1-SNAPSHOT.jar
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.1.5)
2023-11-03T00:22:35.178+01:00 INFO 812 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication v0.0.1-SNAPSHOT using Java 21.0.1 with PID 812 (/mnt/c/Users/LoicG/Downloads/graaljs-community-jvm-23.1.1-linux-amd64.tar/js-java-standalone-svm-java21/demo-0.0.1-SNAPSHOT.jar started by lgr in /mnt/c/Users/LoicG/Downloads/graaljs-community-jvm-23.1.1-linux-amd64.tar/js-java-standalone-svm-java21/graaljs-community-23.1.1-linux-amd64)
2023-11-03T00:22:35.189+01:00 INFO 812 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to 1 default profile: "default"
2023-11-03T00:22:38.741+01:00 INFO 812 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2023-11-03T00:22:38.782+01:00 INFO 812 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-11-03T00:22:38.783+01:00 INFO 812 --- [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.15]
2023-11-03T00:22:38.986+01:00 INFO 812 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-11-03T00:22:38.987+01:00 INFO 812 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3537 ms
2023-11-03T00:22:40.096+01:00 INFO 812 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2023-11-03T00:22:40.136+01:00 INFO 812 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 6.826 seconds (process running for 10.116)
2023-11-03T00:22:47.060+01:00 INFO 812 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-11-03T00:22:47.061+01:00 INFO 812 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2023-11-03T00:22:47.062+01:00 INFO 812 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 0 ms
2023-11-03T00:22:47.277+01:00 ERROR 812 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed: java.lang.ExceptionInInitializerError] with root cause
java.lang.NullPointerException: null
at java.base/java.util.Objects.requireNonNull(Objects.java:233) ~[na:na]
at java.base/sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:296) ~[na:na]
at java.base/java.nio.file.Path.of(Path.java:148) ~[na:na]
at org.graalvm.polyglot.Engine$ClassPathIsolation.collectClassPathJars(Engine.java:1988) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$ClassPathIsolation.createIsolatedTruffleModule(Engine.java:1783) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$ClassPathIsolation.createIsolatedTruffle(Engine.java:1723) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$1.searchServiceLoader(Engine.java:1682) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$1.run(Engine.java:1668) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$1.run(Engine.java:1663) ~[polyglot-23.1.0.jar!/:na]
at java.base/java.security.AccessController.doPrivileged(AccessController.java:319) ~[na:na]
at org.graalvm.polyglot.Engine.initEngineImpl(Engine.java:1663) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$ImplHolder.<clinit>(Engine.java:186) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine.getImpl(Engine.java:438) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$Builder.build(Engine.java:736) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Context$Builder.build(Context.java:1925) ~[polyglot-23.1.0.jar!/:na]
at com.example.demo.DemoController.run(DemoController.java:27) ~[classes!/:0.0.1-SNAPSHOT]
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-6.0.13.jar!/:6.0.13] The required jars are already embedded in the executable jar: Correct me if I am wrong, but the Embedded Languages documentation and the official Polyglot demo specify that, with the Maven dependencies, it should work on Oracle GraalVM 21 (without installing the |
Use this |
This solved my issues too, thanks! |
The solution @Erik-mik suggested works, but the engine runs in the interpreted mode. I get this warning:
|
With the 2023-11-11T21:16:42.874+01:00 ERROR 22624 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed: java.lang.IllegalAccessError: superinterface check failed: class com.oracle.truffle.runtime.OptimizedTruffleRuntime (in unnamed module @0x23ceabc1) cannot access class com.oracle.truffle.compiler.TruffleCompilerRuntime (in module org.graalvm.truffle.compiler) because module org.graalvm.truffle.compiler does not export com.oracle.truffle.compiler to unnamed module @0x23ceabc1] with root cause
java.lang.IllegalAccessError: superinterface check failed: class com.oracle.truffle.runtime.OptimizedTruffleRuntime (in unnamed module @0x23ceabc1) cannot access class com.oracle.truffle.compiler.TruffleCompilerRuntime (in module org.graalvm.truffle.compiler) because module org.graalvm.truffle.compiler does not export com.oracle.truffle.compiler to unnamed module @0x23ceabc1
at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[na:na]
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027) ~[na:na]
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) ~[na:na]
at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:524) ~[na:na]
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:427) ~[na:na]
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:421) ~[na:na]
at java.base/java.security.AccessController.doPrivileged(AccessController.java:714) ~[na:na]
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:420) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:593) ~[na:na]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:149) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[na:na]
at com.oracle.truffle.runtime.enterprise.EnterpriseTruffle.G(stripped:21) ~[truffle-enterprise-23.1.0.jar!/:na]
at com.oracle.truffle.polyglot.enterprise.EnterprisePolyglotImpl.getPriority(stripped:496) ~[truffle-enterprise-23.1.0.jar!/:na]
at java.base/java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:473) ~[na:na]
at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355) ~[na:na]
at java.base/java.util.TimSort.sort(TimSort.java:220) ~[na:na]
at java.base/java.util.Arrays.sort(Arrays.java:1308) ~[na:na]
at java.base/java.util.ArrayList.sort(ArrayList.java:1804) ~[na:na]
at java.base/java.util.Collections.sort(Collections.java:178) ~[na:na]
at org.graalvm.polyglot.Engine.loadAndValidateProviders(Engine.java:1632) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$1.run(Engine.java:1668) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$1.run(Engine.java:1663) ~[polyglot-23.1.0.jar!/:na]
at java.base/java.security.AccessController.doPrivileged(AccessController.java:319) ~[na:na]
at org.graalvm.polyglot.Engine.initEngineImpl(Engine.java:1663) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$ImplHolder.<clinit>(Engine.java:186) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine.getImpl(Engine.java:438) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Engine$Builder.build(Engine.java:736) ~[polyglot-23.1.0.jar!/:na]
at org.graalvm.polyglot.Context$Builder.build(Context.java:1925) ~[polyglot-23.1.0.jar!/:na]
at com.example.demo.DemoController.run(DemoController.java:27) ~[classes!/:0.0.1-SNAPSHOT]
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-6.0.13.jar!/:6.0.13]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-6.0.13.jar!/:6.0.13]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118) ~[spring-webmvc-6.0.13.jar!/:6.0.13]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:884) ~[spring-webmvc-6.0.13.jar!/:6.0.13]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) ~[spring-webmvc-6.0.13.jar!/:6.0.13]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-6.0.13.jar!/:6.0.13]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1081) ~[spring-webmvc-6.0.13.jar!/:6.0.13]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:974) ~[spring-webmvc-6.0.13.jar!/:6.0.13]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1011) ~[spring-webmvc-6.0.13.jar!/:6.0.13]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:903) ~[spring-webmvc-6.0.13.jar!/:6.0.13]
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:564) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885) ~[spring-webmvc-6.0.13.jar!/:6.0.13]
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) ~[tomcat-embed-websocket-10.1.15.jar!/:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-6.0.13.jar!/:6.0.13]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.13.jar!/:6.0.13]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-6.0.13.jar!/:6.0.13]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.13.jar!/:6.0.13]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-6.0.13.jar!/:6.0.13]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.13.jar!/:6.0.13]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:340) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-10.1.15.jar!/:na]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-10.1.15.jar!/:na]
at java.base/java.lang.Thread.run(Thread.java:1583) ~[na:na] It is reproducible with the same code sample. @Erik-mik is this option coming from any documentation ? |
I can confirm that the problem still happens with Spring Boot 3.2 new Nested Jar Support. |
This issue contains an additional workaround: I am working on a better solution for this. |
The issue seems fixed for me since I upgraded to v23.1.2. I do not need to run my jar with the Tested on:
|
Thank you for verifying @loicgreffier! |
Describe GraalVM and your environment :
java -Xinternalversion
:Have you verified this issue still happens when using the latest snapshot?
With the Espresso dev build (https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/24.0.0-dev-20231010_0216/espresso-community-dev-macos-aarch64.tar.gz) the issue does not happen. I cannot find a non-espresso build.
Describe the issue
When attempting to load a Javascript source file from code running within an executable JAR built by the Spring Boot Maven plugin (I'm using version 3.1.4), an exception is thrown. The exception seems to come from the
Engine
class initialization code. From what I've seen digging through the stack trace and code dependencies are assumed to reside on the file system. Based on this assumption, when the classloader returns the list of dependencies from the JAR file the call to convert theURL
to aPath
returnsnull
which causesPath.of
to throw an NPE.Is this a bug or expected behavior? Have I misconfigured something? If this is expected behavior, then what is the correct way to package a GraalVM polyglot application?
Code snippet or code repository that reproduces the issue
Steps to reproduce the issue
Please include both build steps as well as run steps
Expected behavior
GraalVM polyglot code initializes correctly and the program executes without issue. That is, no exception is thrown.
Additional context
Add any other context about the problem here. Specially important are stack traces or log output. Feel free to link to gists or to screenshots if necesary
Details
The text was updated successfully, but these errors were encountered: