Search code examples
javajavafxosgiapache-felix

JavaFx + Felix on windows WinPlatformFactory not found


I have a desktop application that uses Apache felix and swing, with embebed javafx UIs, javafx is being loaded into the project by a maven embebed dependency, and it works fine on mac.

But when i run it on windows it gives me the following error:

java.lang.ClassNotFoundException: com.sun.glass.ui.win.WinPlatformFactory not found by my-software [38]
    at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1574)
    at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)
    at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(undleWiringImpl.java:2018)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at com.sun.glass.ui.PlatformFactory.getPlatformFactory(PlatformFactory.java:42)
    at com.sun.glass.ui.Application.run(Application.java:146)
    at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:257)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
    at javafx.embed.swing.JFXPanel.initFx(JFXPanel.java:215)
    at javafx.embed.swing.JFXPanel.<init>(JFXPanel.java:230)
    at br.com.mysoftware.fx.java.DownloadExplorer.initAndShowGUI(DownloadExplorer.java:68)
    at br.com.mysoftware.fx.java.DownloadExplorer$1.run(DownloadExplorer.java:120)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)____________________________Welcome to Apache Felix Gogo


    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)

    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) Failed to load Glass factory class Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at com.sun.glass.ui.Application.run(Application.java:146)
    at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:257)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
    at javafx.embed.swing.JFXPanel.initFx(JFXPanel.java:215)
    at javafx.embed.swing.JFXPanel.<init>(JFXPanel.java:230)
    at br.com.mysoftware.fx.java.DownloadExplorer.initAndShowGUI(DownloadExplorer.java:68)
    at br.com.mysoftware.fx.java.DownloadExplorer$1.run(DownloadExplorer.java:120)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)

    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Solution

  • javafx is being loaded into the project by a maven embebed dependency

    I don't think embedding the javafx jar is the correct approach, if that is what you're doing. You'll be missing some native parts, I guess.

    Rather use the "org.osgi.framework.system.packages.extra" mechanism.

    You can have a look at the Dromber FX code (the modular application framework for JavaFX, which combines JavaFX and OSGi ; I'm the author of this framework):

    https://github.com/Drombler/drombler-fx/blob/release-0.9/drombler-fx-startup-main/src/main/resources/org/drombler/fx/startup/main/config.properties