How do I make jfxrt.jar available?
randahl Mar 25, 2014 9:15 AMBoth in my rich client and in my EJBs I am using a framework which can optionally be used with JavaFX. This means that when my EJBs are running inside WildFly the JavaFX runtimer jar jfxrt.jar needs to be available.
Since Java 8, jfxrt.jar has moved into the $JAVA_HOME/jre/lib/ext folder, which means the jfxrt.jar classes are loaded automatically if you start a JavaFX based application.
However, when I deploy to WildFly I get typical WildFly StartException caused by:
java.lang.NoClassDefFoundError: javafx/scene/Node
This tells me, that WildFly does not load JavaFX automatically. I have been reading up on WildFly class loading and modules, and it seems I am supposed to define jfxrt.jar as a WildFly module, so first I have created the folder
wildfly-8.0.0.Final/modules/system/layers/base/javafx/api/main
and inside that folder I have created a module.xml file containing this XML:
<module xmlns="urn:jboss:module:1.1" name="javafx.api">
<dependencies>
<system export="true">
<paths>
<path name="javafx/animation"/>
<path name="javafx/application"/>
[…]
With a path for each of the javafx packages.
This, however, had no effect, so I tried adding a dependency on this module, by typing this in my ejb.jar's manifest.mf file:
Dependency: javafx.api
This also had no effect. Then I tried telling WildFly to always make the javafx.api module available globally by adding this to WildFly's domain.xml file:
<profile name="default">
<!-- javafx -->
<subsystem xmlns="urn:jboss:domain:ee:1.0" >
<global-modules>
<module name="javafx.api" slot="main"/>
</global-modules>
</subsystem>
[…]
This also had no effect.
Now, I know could copy jfxrt.jar directly into my WildFly module, but that's not what I am looking for. Rather, I want WildFly to make available whatever JavaFX classes the JRE comes with – just like the JDK does, when I run an app on the comand line. I would be grateful, if anyone could offer some ideas for how to do that.