You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In out Eclipse Product, we are moving away from using Nashorn Engine to GraalJS Engine. But, due to some constraints, I'm currently unable to make it work.
We have a project named 'org.graalvm.js' and has added all the required jars into the libraries folder and added it to the classpath. Extracted all the ServiceRegistry file to META-INF folder.
And created my own plugin named 'com.pal.script' and in MyGraalJSScriptEngine class (in same plugin), I have tried to use the load a class from Host. I tried the same class itself. But, it says
Caused by: org.graalvm.polyglot.PolyglotException: TypeError: Access to host class com.bosch.wbp.scripting.commandline.WBPGraalJSScriptEngine is not allowed or does not exist. at <js>.:program(<eval>:1) at org.graalvm.polyglot.Context.eval(Context.java:402) at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:490) ... 36 more
The code is:
public MyGraalJSScriptEngine() { super("Graal VM"); System.setProperty("polyglot.engine.WarnInterpreterOnly", "false"); final ScriptEngineManager engineManager = new ScriptEngineManager(); this.fEngine = (GraalJSScriptEngine) engineManager.getEngineByName("GraalJS"); Bindings bindings = this.fEngine.getBindings(ScriptContext.ENGINE_SCOPE); bindings.put("polyglot.js.allowHostAccess", true); bindings.put("polyglot.js.allowHostClassLookup", (Predicate<String>) s -> { return true; }); this.fEngine.getBindings(ScriptContext.ENGINE_SCOPE).put("javaObj", new Object()); String script = "(javaObj instanceof Java.type('com.pal.MyGraalJSScriptEngine'));"; try { this.fEngine.eval("(javaObj instanceof Java.type('java.lang.Object'));"); this.fEngine.eval(script); // This is not working } catch (ScriptException e) { e.printStackTrace(); } }
Any help would be appreciated.
Thanks,
Palraj
The text was updated successfully, but these errors were encountered:
I am sorry, but the information that you have provided is not sufficient to track the problem down. For example, your error mentions WBPGraalJSScriptEngine but this class/string is not part of the short code snippet that you have provided. Please, provide more information. It would be ideal to described exact steps that lead to the problem that you are facing. Thank you in advance.
In out Eclipse Product, we are moving away from using Nashorn Engine to GraalJS Engine. But, due to some constraints, I'm currently unable to make it work.
We have a project named 'org.graalvm.js' and has added all the required jars into the libraries folder and added it to the classpath. Extracted all the ServiceRegistry file to META-INF folder.
I have refered to the help documentation at: https://www.graalvm.org/latest/reference-manual/js/ScriptEngine/
And created my own plugin named 'com.pal.script' and in MyGraalJSScriptEngine class (in same plugin), I have tried to use the load a class from Host. I tried the same class itself. But, it says
Caused by: org.graalvm.polyglot.PolyglotException: TypeError: Access to host class com.bosch.wbp.scripting.commandline.WBPGraalJSScriptEngine is not allowed or does not exist. at <js>.:program(<eval>:1) at org.graalvm.polyglot.Context.eval(Context.java:402) at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:490) ... 36 more
The code is:
Any help would be appreciated.
Thanks,
Palraj
The text was updated successfully, but these errors were encountered: