Hi
I'm trying to embed graalJS engine inside OSGI container...
Here is my code:
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value;
...
final Context context = Context.newBuilder("js")
.allowAllAccess(true)
.allowIO(true)
.allowCreateThread(true)
.allowHostClassLoading(true)
.allowHostAccess(true)
.allowNativeAccess(true)
.build();
final Value v = context.eval("js", "8+3");
last line throws PolyglotIllegalArgumentException: _A language with id 'js' is not installed. Installed languages are: []._
After some debugging it looks like TruffleLocator can't see class loader with JavaScriptLanguage.class (or any other language) - because, in my case jar-s with languages are embedded in osgi bundle and separate class loader is used for each of them)
I can't find any method to register eg JavaScriptLanguage manually in LanguageCache (or any other place) or pass additional classloaded to the TruffleLocator (or Context builder ideally)
Is there a way to register Language manually? Am I missing something?
Thanks for the report. We did not test with OSGI containers yet, so possible that we have a problem here.
Could you please specify how you run? (GraalVM?, JDK?)
Also I am not very familiar with OSGI, maybe you have a simple reproducer somewhere ready? That would help me a lot.
Minor note: If you specify allowAllAccess no other access rights need to be specified, they are implicit including all new access rights we will introduce.
Hi
Ok, so I assume that answer to my question is "no, there is no other way to register languages".
In the next week I will try to share minimal setup (this includes some kind of osgi framework) needed to reproduce the issue.
I successfuly managed to get polyglot working in OSGI by adding org.graalvm.polyglot
to org.osgi.framework.system.packages.extra
Cool! so the issue is safe to close?
Maybe just wait for @subiron to confirm?
Naturally, the questions was more for @subiron :)
I apologize for the lack of an earlier answer.
@doddi thanks for a hint, unfortunately this might be a little tricky to implement in my case (corporate issues) although it will work.
Most helpful comment
I successfuly managed to get polyglot working in OSGI by adding
org.graalvm.polyglottoorg.osgi.framework.system.packages.extra