Problem running JavaFX in maven plugins

Dan Armbrust daniel.armbrust.list at
Fri Jan 4 06:28:41 UTC 2019

As a followup, the easiest workaround I found is this silly hack:

                      String s = System.getProperty("javafxHack");
                      int i = 0;
                      if (!StringUtils.isBlank(s))
                         i = Integer.parseInt(s);
                      System.setProperty("javafxHack", i + "");
                      System.setProperty("javafx.version", "mavenHack" + i);

Which I run before calling PlatformImpl.startup();
This way, each classloader that launches JavaFX gets its own copy of the dll.

It would be nice if the JavaFX code itself handled the dll's better to not have this issue 
- this is a regression from JDK 8.

But I do realize its probably a rare usecase... I run into it because I have multiple 
instantiations of a plugin that runs during a maven lifecycle that utilizes the tasks API, 
among other things.

But this will also break for anyone that tries to use parts of JavaFX in a server like 
tomcat where classloaders are isolated. But that might not be a common issue either unless 
the very old feature request about JavaFX not supporting running Headless get fixed.

I currently use our own hacked implementation of a ToolKit to inject when running 
headless, in order to make the tasks API work.


On 12/31/2018 09:54 PM, Dan Armbrust wrote:
> Hi,
> I'm trying to migrate a codebase to JDK 11 / OpenJFX, and have run into an issue I 
> didn't have under JDK 8.
> We have a complex maven build process - parts of which include building our own maven 
> plugins, and then executing those plugins in a different portion of the build.
> Maven uses isolated Plugin Classloaders for each plugin execution: 
> When my plugin executes, its going down a path that needs to start up the JavaFX 
> subsystem - mostly to get support for tasks and such (we are actually building headless, 
> with a hack of a HeadlessToolkit shimmed in to make JavaFX actually work headless) but - 
> it would appear that because some other class loader in my build process already hit the 
> JavaFX startup once... I fail on a native library load:
> Loading library glass from resource failed: java.lang.UnsatisfiedLinkError: Native 
> Library /home/darmbrust/.openjfx/cache/11/ already loaded in another classloader
> java.lang.UnsatisfiedLinkError: Native Library 
> /home/darmbrust/.openjfx/cache/11/ already loaded in another classloader
>         at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(
>         at java.base/java.lang.ClassLoader.loadLibrary0(
>         at java.base/java.lang.ClassLoader.loadLibrary(
>         at java.base/java.lang.Runtime.load0(
>         at java.base/java.lang.System.load(
>         at 
>         at 
>         at
>         at
>         at
>         at
>         at$static$2(
>         at java.base/ Method)
>         at<clinit>(
>         at 
>         at
>         at
>         at com.sun.javafx.application.PlatformImpl.startup(
> Any suggestions on how to deal with this?
> I'm running on linux with:
> openjdk 11.0.1 2018-10-16
> OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
> OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
> I'm going to try this hack and see if it works: 
> But it would be nice to have a proper solution for this.
> Also, on a completely unrelated note, where the heck is the JavaFX bug tracker these 
> days?  There seems to be no end to confusing information out there about where the bug 
> tracker is, multiple github mirrors have trackers, and the place that should clarify 
> this says nothing:
> Multiple Oracle pages still point to the Jira, many other pages point to the 
>, others point to but that shows no 
> javafx project.
> Is this one official now?
> Thanks,
> Dan

More information about the openjfx-dev mailing list