Skip to content
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

GraalVM JS Engine does not work with version 3.8.3 #39833

Closed
csviri opened this issue Apr 2, 2024 · 18 comments
Closed

GraalVM JS Engine does not work with version 3.8.3 #39833

csviri opened this issue Apr 2, 2024 · 18 comments
Labels
kind/bug Something isn't working triage/needs-feedback We are waiting for feedback.

Comments

@csviri
Copy link

csviri commented Apr 2, 2024

Describe the bug

When want to use graalvm js with quarkus 3.8.3, the js engine cannot be instantiated, receiving message:

ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory: Provider com.oracle.truffle.js.scriptengine.GraalJSEngineFactory could not be instantiated

created a reproducer here:
https://github.com/csviri/quarkus-graalvm-js-reproducer

Note that this uses graalvm version 23.1.2.
With GraalVM version 24.0.0 the engine can be instantiated but I receive an error:

java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:113)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.NoClassDefFoundError: org/graalvm/collections/UnmodifiableEconomicSet
	at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.createNashornHostAccess(GraalJSScriptEngine.java:105)
	at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.<clinit>(GraalJSScriptEngine.java:102)
	at com.oracle.truffle.js.scriptengine.GraalJSEngineFactory.getScriptEngine(GraalJSEngineFactory.java:151)
	at java.scripting/javax.script.ScriptEngineManager.lambda$getEngineBy$2(ScriptEngineManager.java:237)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.tryAdvance(StreamSpliterators.java:300)
	at java.base/java.util.stream.Streams$ConcatSpliterator.tryAdvance(Streams.java:723)
	at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
	at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647)
	at java.scripting/javax.script.ScriptEngineManager.getEngineBy(ScriptEngineManager.java:246)
	at java.scripting/javax.script.ScriptEngineManager.getEngineByName(ScriptEngineManager.java:185)
	at org.acme.Main$MyApp.run(Main.java:28)
	at org.acme.Main_MyApp_ClientProxy.run(Unknown Source)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:132)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
	at org.acme.Main.main(Main.java:15)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	... 3 more
Caused by: java.lang.ClassNotFoundException: org.graalvm.collections.UnmodifiableEconomicSet
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	... 25 more

See branch graal-24 in same repo.

Expected behavior

Java sctript engine instantiated and can execute scripts.

Actual behavior

No response

How to Reproduce?

Use the mentioned reproducer project. Just simply run the project on main branch.

Output of uname -a or ver

Linux csviri-desctop 5.15.0-101-generic #111-Ubuntu SMP Tue Mar 5 20:16:58 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk 21.0.2 2024-01-16

Quarkus version or git rev

3.8.3

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae) Maven home: /home/csviri/Applications/apache-maven-3.9.6 Java version: 21.0.2, vendor: Private Build, runtime: /usr/lib/jvm/java-21-openjdk-amd64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.15.0-101-generic", arch: "amd64", family: "unix"

Additional information

No response

@csviri csviri added the kind/bug Something isn't working label Apr 2, 2024
@geoand
Copy link
Contributor

geoand commented Apr 2, 2024

Thanks for reporting @csviri.

@zakkak didn't we encounter something similar recently?

@csviri
Copy link
Author

csviri commented Apr 2, 2024

Some additional info, strangely if run the project through main (not quarkus plugin from intellij) or just building an uber-jar and running that this work with graalvm 24.0.0.

@geoand
Copy link
Contributor

geoand commented Apr 2, 2024

or just building an uber-jar

I kind of expected this honestly as the issue is likely certainly ClassLoader related

@gsmet
Copy link
Member

gsmet commented Apr 2, 2024

As for GraalVM 24 error, there might be some artifacts missing as parent first.

@gsmet
Copy link
Member

gsmet commented Apr 2, 2024

But I wasn't able to reproduce your java.lang.ClassNotFoundException: org.graalvm.collections.UnmodifiableEconomicSet error.

@csviri
Copy link
Author

csviri commented Apr 2, 2024

But I wasn't able to reproduce your java.lang.ClassNotFoundException: org.graalvm.collections.UnmodifiableEconomicSet error.

for for (24.0.0) was also happening in dev mode, just running simply mvn quarkus:dev.

@gsmet
Copy link
Member

gsmet commented Apr 2, 2024

I wonder if I misunderstood: you're tring GraalVM 24.0.0 with 3.8.3 and it doesn't work but it works with 3.9.1?

@csviri
Copy link
Author

csviri commented Apr 2, 2024

It does not work with 3.9.1 either. First I thought it does , but just tried it running differently.
So it works when I run it with a built Uber jar (for 3.8.3 also).

@zakkak
Copy link
Contributor

zakkak commented Apr 2, 2024

@csviri I can't reproduce the issue with:

sdk install java 21.0.2-graalce
export JAVA_HOME=~/.sdkman/candidates/java/21.0.2-graalce
git clone https://github.com/csviri/quarkus-graalvm-js-reproducer
cd quarkus-graalvm-js-reproducer
mvn verify
$JAVA_HOME/bin/java -jar /home/zakkak/code/tmp/quarkus-graalvm-js-reproducer/target/quarkus-app/quarkus-run.jar
mvn quarkus:dev

I tried both Quarkus 3.8.3 and 3.9.1. Are you doing something different? Can you please provide step by step instructions on how to reproduce? Thanks

Update: I also tried the graal-24 branch with:

sdk install java 22-graalce
export JAVA_HOME=~/.sdkman/candidates/java/21.0.2-graalce

and still couldn't reproduce the issue.

@gsmet
Copy link
Member

gsmet commented Apr 2, 2024

I was able to reproduce the issue with 3.8.3 but 3.9.1 works for me (but I'm actually surprised it works)

@geoand
Copy link
Contributor

geoand commented Apr 4, 2024

I also tried what @zakkak tried and everything worked

@barreiro
Copy link
Contributor

barreiro commented Apr 4, 2024

I'm using openJDK-17 and I can reproduce the error. I see some of the graal jars are missing from target/quarkus-app/libs/boot.
I can also confirm that @gsmet fixes the issue for me.

gsmet added a commit to gsmet/quarkus that referenced this issue Apr 9, 2024
gsmet added a commit to gsmet/quarkus that referenced this issue Apr 9, 2024
gsmet added a commit to gsmet/quarkus that referenced this issue Apr 9, 2024
gsmet added a commit to gsmet/quarkus that referenced this issue Apr 11, 2024
gsmet added a commit to gsmet/quarkus that referenced this issue Apr 11, 2024
@stalep
Copy link
Member

stalep commented Apr 12, 2024

Hi @gsmet, would it be possible to get this into 3.8.4?

@gsmet
Copy link
Member

gsmet commented Apr 15, 2024

Hey @stalep , we discussed it with Luis last week and I can confirm the fix will be released with 3.8.4. I plan to release 3.8.4 on Wednesday.

@gsmet
Copy link
Member

gsmet commented Apr 15, 2024

You can test the 3.8 branch already if you want to make sure everything is fine on your side.

ketola pushed a commit to ketola/quarkus that referenced this issue May 1, 2024
@geoand
Copy link
Contributor

geoand commented May 17, 2024

Has this since been fixed?

@geoand geoand added the triage/needs-feedback We are waiting for feedback. label May 17, 2024
@gsmet gsmet closed this as completed May 17, 2024
@gsmet
Copy link
Member

gsmet commented May 17, 2024

Yes!

@geoand
Copy link
Contributor

geoand commented May 17, 2024

👌🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working triage/needs-feedback We are waiting for feedback.
Projects
None yet
Development

No branches or pull requests

6 participants