I want to use GraalVM (version 22.0.0.2 with Java 17.0.2) to execute JavaScripts within Wildfly (version 26.0).
If I do have the following code:
System.out.println("Polyglot class: "+PolyglotException.class);
then my JSE unit test, started from Eclise, works fine. But if I call the same code within my EAR within Wildfly, I get an
java.lang.ClassNotFoundException: org.graalvm.polyglot.PolyglotException
What’s wrong? How can I inform Wildfly that the org.graalvm classes are available?
Solution:
Thanks to ehsavoie for the hint! I already had such an idea but did something wrong when testing.
You do have to do the following:
Put in your file
jboss-dependendt-structure.xml
something like:<jboss-deployment-structure> <deployment> <dependencies> <module name="org.graalvm" export="true"/> </dependencies> </deployment> </jboss-deployment-structure>
define a file within `modules/org/graalvm/main/module.xml’ with content like:
<module name="org.graalvm" xmlns="urn:jboss:module:1.6"> <properties> <property name="jboss.api" value="public"/> </properties> <dependencies> <system export="true"> <paths> <path name="org/graalvm/polyglot"/> <!-- probably more packages will follow, but this is enough for the example --> </paths> </system> </dependencies> </module>
Sorry if there are any typos in upper examples. I hope, future Wildfly versions will maybe contain such a file automatically. For the moment, I am happy that it’s working at all.
Advertisement
Answer
You would have to add dependency on the org.graavml.polyglot module in your application or expose it like what is done with the module /sun/scripting/main/