codecentric / NSMenuFX

Other
128 stars 27 forks source link

de.codecentric.centerdevice.dialogs.about.AboutController not found #20

Closed winnall closed 6 years ago

winnall commented 7 years ago

I am using NSMenuFX 2.1.4 in an OSGi (Felix 5.4.0) application with JDK 1.8.0_76-ea on an iMac running macOS Sierra 10.12.3. Other relevant software involved: NetBeans 8.2, Maven 3.3.3.

After a call tomenu = menuToolkit.createDefaultApplicationMenu("ABC"); I get the following stack dump:

javafx.fxml.LoadException: 
/about.fxml:7

    at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
    at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:103)
    at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:922)
    at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:971)
    at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220)
    at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744)
    at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
    at de.codecentric.centerdevice.dialogs.about.AboutStageBuilder.prepareStage(AboutStageBuilder.java:44)
    at de.codecentric.centerdevice.dialogs.about.AboutStageBuilder.build(AboutStageBuilder.java:35)
    at de.codecentric.centerdevice.MenuToolkit.createDefaultAboutStage(MenuToolkit.java:90)
    at de.codecentric.centerdevice.MenuToolkit.createDefaultApplicationMenu(MenuToolkit.java:66)

        ...

Caused by: java.lang.ClassNotFoundException: de.codecentric.centerdevice.dialogs.about.AboutController
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:920)
    ... 23 more

The bundle is loaded and active:

g! lb
START LEVEL 1
   ID|State      |Level|Name
   ...
   12|Active     |    1|CenterDevice NSMenuFX (2.1.4)|2.1.4
   ...
0x4a616e commented 7 years ago

Hi,

thanks for the report. That seems like an OSGI related issue. I've found a blog post that seems to describe this issue a bit further: http://blog.admadic.com/2013/03/javafx-fxmlloader-with-osgi.html

Can you maybe try to call

FXMLLoader.setDefaultClassLoader(AboutStageBuilder.class.getClassLoader());

before calling menu = menuToolkit.createDefaultApplicationMenu("ABC"); and see if that solves the issue?

winnall commented 7 years ago

Thanks for the swift response. This makes sense (threads and classloaders tend to be a problem where JavaFX meets OSGi) but I can't test it at the moment (big ongoing refactorisation). I'll get back to you when I've tried it out.

Steve

On 27 Jan 2017, at 11:54, Jan Gassen notifications@github.com wrote:

Hi,

thanks for the report. That seems like an OSGI related issue. I've found a blog post that seems to describe this issue a bit further: http://blog.admadic.com/2013/03/javafx-fxmlloader-with-osgi.html

Can you maybe try to call

FXMLLoader.setDefaultClassLoader(AboutStageBuilder.class.getClassLoader()); before calling menu = menuToolkit.createDefaultApplicationMenu("ABC"); and see if that solves the issue?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.