Javafx in Ignition 8 module

We have had some Javafx components in our module in Ignition 7.9. Now with the release of Ignition 8.0 we want to make our module work with the new version but we are having some issues with Javafx. We have added the Javafx dependencies to Maven but when we launch the designer with the module we get the following error in the console:
java.lang.NoClassDefFoundError: javafx/embed/swing/JFXPanel

Does anyone have a solution?

Can you share your module and/or its pom.xml files?

I can’t upload the files to the forums so here is a pastebin:

client pom: https://pastebin.com/4L7827wZ
java class: https://pastebin.com/qv0FH1ff

If you open the module that gets built can you find those jar files? Are the references to those jars included in the module.xml file?

I’m not exactly sure what you mean by module.xml but when I add the module on the gateway the javafx jars are added to the jar-cache of the module.

When you build your module there should be a module.xml file inside of it - can you post that?

Here is my module.xml:
I am able to find the javafx jars in the module.

module.xml (2.0 KB)

Not sure what’s wrong right now. You’ve got duplicate jar entries in the module.xml but I’m not sure if that’s a problem.

If you launch the designer with the java console enabled is there errors?

The problem is JavaFX is not included with the JVM that ships with the launchers. You will need to add the JavaFX binaries from openjfx.io to .ignition\cache\resources\runtimes\someversion and I think it will work.

1 Like

I am not exactly sure how I can show the console with Zulu JRE that has been added to Ignition 8.

This worked! I replaced the Zulu JDK with the version that has OpenJFX included and now it works. Unfortunatly adding OpenJFX for every client is not a good solution.

Ah, right…

Look in ~/.ignition/clientlauncher-data/clientlauncher.log

You’ll see a line like this:

INFO  [ClientLauncherFrame           ] [12:40:57,735]: Starting Java with the following parameters:nohup /usr/lib/jvm/java-9-jdk/bin/java -classpath /home/kevin/.ignition/clientlauncher-data/launchclient.jar -Djavaws.sr.gateway.addr.0=10.10.70.68:8088/main -Djavaws.sr.scope=D -Djavaws.sr.launchts=1545079238938 -Djavaws.sr.main=com.inductiveautomation.ignition.designer.DesignerStartupHook -Djavaws.sr.platform.edition= -Xms256M -Xmx1024M -Dsun.java2d.d3d=false com.inductiveautomation.ignition.client.launch.BootstrapSwing & 

Copy that launch command and launch a client yourself from a terminal. You should be able to see the logs.

Ah oké got that working. No errors in the client logs though.

Can you send a copy of your module via email or DM?

Hmm, seems like there’s some missing JARs in the module that gets built.

Try adding explicit dependencies on javafx-graphics and javafx-media.

When I list your client module’s dependencies with Maven I get this:

kevin@Kevins-2018-MacBook-Pro ~/D/O/C/corporateidentity-client>
mvn dependency:list -DincludeScope=compile -DexcludeScope=test | grep ".*:.*:.*compile" | cut -d] -f2- | sort -u
    eu.hansolo:Medusa:jar:8.3:compile
    jfree:jcommon:jar:1.0.16:compile
    jfree:jfreechart:jar:1.0.13:compile
    nl.at_automation:corporateidentity-common:jar:1.2.1:compile
    org.openjfx:javafx-base:jar:11:compile
    org.openjfx:javafx-base:jar:mac:11:compile
    org.openjfx:javafx-controls:jar:11:compile
    org.openjfx:javafx-controls:jar:mac:11:compile
    org.openjfx:javafx-graphics:jar:11:compile
    org.openjfx:javafx-graphics:jar:mac:11:compile
    org.openjfx:javafx-media:jar:11:compile
    org.openjfx:javafx-media:jar:mac:11:compile
    org.openjfx:javafx-swing:jar:11:compile
    org.openjfx:javafx-swing:jar:mac:11:compile
    org.openjfx:javafx-web:jar:11:compile
    org.openjfx:javafx-web:jar:mac:11:compile

Aside from the fact that you’re missing some of those jars in the final module.xml and module, those system-specific classifiers are gonna be another problem to figure out - the JavaFX jars have native components and you’ll have to package all the variants for every platform you want to support.

You may just need a bunch of explicit dependencies for each javafx artifact, one for the base artifact, and an additional one for each platform for that artifact.

edit: that might not be right, I’m not sure if you can just include all the native artifacts or if you need to somehow get it right for the platform it’s launching on…

It also doesn’t seem like the ignition-maven-plugin knows to look at the <classifier> element on a dependency and treat it differently, so we might be kinda stuck right now.

Ant to the rescue? /-:

Or maintain the module.xml by hand and write a small shell script to collect the dependencies and zip everything up. It’s pretty easy, some of the first modules I wrote years ago were built that way.

I’m doing a similar thing with a run-once python script to soft-link all my dependencies and ant to build and package and sign. Very flexible.

That doesn’t sound that bad. Will give it a try.