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

[23.1.0] Unable to find truffle-api/polyglott in embedded assembly #764

Closed
ctabin opened this issue Sep 21, 2023 · 5 comments
Closed

[23.1.0] Unable to find truffle-api/polyglott in embedded assembly #764

ctabin opened this issue Sep 21, 2023 · 5 comments
Assignees
Labels
question Further information is requested wontfix This will not be worked on

Comments

@ctabin
Copy link

ctabin commented Sep 21, 2023

Hi,

We are building a full assembly with GraalJS embedded in it. I created a simple project that easily reproduce the problem.

To summarize:

  • when executed through maven with mvn -q exec:java, it works (meaning the dependencies are correctly declared).
  • when executed through the command line on the full assemply with java -jar target/polyglott-full-embedded.jar, it crashes.

When launched with -Dpolyglotimpl.TraceClassPathIsolation=true, the output is:

[class-path-isolation] Start polyglot class-path isolation
[class-path-isolation] Collected 1 class-path entries from java.class.path system property
[class-path-isolation] Class-path entry: target/polyglott-full-embedded.jar
[class-path-isolation] No truffle-api and/or polyglot found on classpath. 
Exception in thread "main" java.lang.IllegalStateException: No language and polyglot implementation was found on the class-path. Make sure at last one language is added on the class-path. If you put a language on the class-path and you encounter this error then there could be a problem with isolated class loading. Use -Dpolyglotimpl.TraceClassPathIsolation=true to debug class loader islation problems. For best performance it is recommended to use polyglot from the module-path instead of the class-path.
        at org.graalvm.polyglot.Engine$PolyglotInvalid.noPolyglotImplementationFound(Engine.java:2071)
        at org.graalvm.polyglot.Engine$PolyglotInvalid.createHostAccess(Engine.java:2057)
        at org.graalvm.polyglot.Engine$PolyglotInvalid.createHostAccess(Engine.java:2023)
        at org.graalvm.polyglot.Engine$Builder.build(Engine.java:753)
        at ch.astorm.Main.main(Main.java:9)

One can see that truffle-api and/or polyglot is not found in the jar, but the classes are present in the assembly, hence there seems to be no reason to not to be found.

As a side note, this was perfectly working in 23.0.1 (by using the old maven artifacts).

Thanks & best regards.

@iamstolis
Copy link
Member

This issue has nothing to do with graal-js. It is a failure of the initialization of Polyglot SDK.

One can see that truffle-api and/or polyglot is not found in the jar, but the classes are present in the assembly, hence there seems to be no reason to not to be found.

The failure is not about the classes themselves. It is about some module-related meta-data that your approach does not satisfy.

I will let @chumer to comment on whether this something that we support still and how.

@ctabin
Copy link
Author

ctabin commented Sep 22, 2023

It seems I found a way to circumvent this problem in assembly:

java -Dpolyglotimpl.DisableClassPathIsolation=true -jar target/polyglott-full-embedded.jar

@thmarx
Copy link

thmarx commented Oct 8, 2023

This is an issue for me too.

@chumer
Copy link
Member

chumer commented Oct 10, 2023

I fear the Maven assembly plugin merges all dependencies into a single uber jar by default. Uber jars won't work with optimizations enabled since the optimizing runtime needs to run as a named module. The module information gets lost when creating the uber jar. The reason we need to run as a named module is that we need to access VM internals to perform optimizations and that is only possible when running as a named module. If you cannot use something else than an uber jar I fear the only option is to use -Dpolyglotimpl.DisableClassPathIsolation=true and run without optimizations enabled.

If you are using zip assemblies with a regular class path everything should work fine.
We generally recommend running using the module path for best performance if possible.

@chumer chumer closed this as not planned Won't fix, can't repro, duplicate, stale Oct 10, 2023
@chumer chumer added question Further information is requested wontfix This will not be worked on labels Oct 10, 2023
@chumer chumer reopened this Jan 29, 2024
@chumer
Copy link
Member

chumer commented Jan 29, 2024

Maven Assemblies are now supported again with 23.1.2 and 24.0. I would still not recommend it, though.
See https://github.com/graalvm/polyglot-embedding-demo/blob/main/pom.xml#L315 for an example how to correctly configure it.

@chumer chumer closed this as completed Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants