1. Gluon-OSS
  2. Gluon-OSS
  3. SceneBuilder
  4. Issues
Issue #64 resolved

SceneBuilder fails to open with custom controls - from eclipse

Anonymous created an issue

Hello, I have imported a custom control into SceneBuilder, and if I launch from windows start menu, then I can open my fxml. When I open from eclipse using - Open With SceneBuilder I get the following error:

java.io.IOException: javafx.fxml.LoadException: /C:/workspace/alpha-powersuiteui/powersuitefx-master-module/javafx-policy/src/main/resources/fxml/PolicyPeriodWorkspace.fxml

at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:92)
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:82)
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:97)
at com.oracle.javafx.scenebuilder.kit.editor.EditorController.updateFxomDocument(EditorController.java:2384)
at com.oracle.javafx.scenebuilder.kit.editor.EditorController.setFxmlTextAndLocation(EditorController.java:664)
at com.oracle.javafx.scenebuilder.app.DocumentWindowController.loadFromFile(DocumentWindowController.java:381)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performOpenFiles(SceneBuilderApp.java:554)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.handleOpenFilesAction(SceneBuilderApp.java:424)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.handleLaunch(SceneBuilderApp.java:403)
at com.oracle.javafx.scenebuilder.app.AppPlatform.requestStartGeneric(AppPlatform.java:139)
at com.oracle.javafx.scenebuilder.app.AppPlatform.requestStart(AppPlatform.java:106)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.start(SceneBuilderApp.java:353)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$149(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)

Caused by: javafx.fxml.LoadException: /C:/workspace/alpha-powersuiteui/powersuitefx-master-module/javafx-policy/src/main/resources/fxml/PolicyPeriodWorkspace.fxml

at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2848)
at javafx.fxml.FXMLLoader.processImport(FXMLLoader.java:2692)
at javafx.fxml.FXMLLoader.processProcessingInstruction(FXMLLoader.java:2661)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2517)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2425)
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:89)
... 20 more

Caused by: java.lang.ClassNotFoundException: org.idahosif.custom.controls.CopyableLabel at java.lang.ClassLoader.findClass(ClassLoader.java:530) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at javafx.fxml.FXMLLoader.loadTypeForPackage(FXMLLoader.java:2916) at javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:2905) at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2846) ... 25 more

If I open SceneBuilder using Open With SceneBuilder from Eclipse on a different FXML not using that component it opens, and then I can open my FXML.

I am thinking that there is an issue with classpath when launching from Eclipse?

Comments (19)

  1. Adam Paul

    Purringpigeon, if you modify the app.classpath variable in SceneBuilder.cfg to include the jars with the custom elements then you are able to open from eclipse and Netbeans.

  2. Jose Pereda

    Version 8.2.0 should fix this issue without the need of editing the config file. Just add the custom jar to the library and the next time you open the FXML from your IDE it should open normally, without CNFE.

    Check it and we'll close this issue.

  3. Purring Pigeon

    I tried this new build today and unfortunately I have the same issue. If I open it once SceneBuilder is running then it works just fine.

    I checked that the jars are in SceneBuilder and what version was running. This version didn't appear to fix the issue....

    java.io.IOException: javafx.fxml.LoadException: /C:/workspace/beta-powersuiteui/sifcomp-master-module/javafx-policy/src/main/resources/fxml/PolicyPeriodWorkspace.fxml

                at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:92)
                at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:82)
                at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:97)
                at com.oracle.javafx.scenebuilder.kit.editor.EditorController.updateFxomDocument(EditorController.java:2384)
                at com.oracle.javafx.scenebuilder.kit.editor.EditorController.setFxmlTextAndLocation(EditorController.java:664)
                at com.oracle.javafx.scenebuilder.app.DocumentWindowController.loadFromFile(DocumentWindowController.java:384)
                at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performOpenFiles(SceneBuilderApp.java:566)
                at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.lambda$handleOpenFilesAction$86(SceneBuilderApp.java:436)
                at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
                at java.security.AccessController.doPrivileged(Native Method)
                at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294)
                at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
                at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
                at com.sun.glass.ui.win.WinApplication.lambda$null$149(WinApplication.java:191)
                at java.lang.Thread.run(Thread.java:745)
    

    Caused by: javafx.fxml.LoadException: /C:/workspace/beta-powersuiteui/sifcomp-master-module/javafx-policy/src/main/resources/fxml/PolicyPeriodWorkspace.fxml

                at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
                at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2848)
                at javafx.fxml.FXMLLoader.processImport(FXMLLoader.java:2692)
                at javafx.fxml.FXMLLoader.processProcessingInstruction(FXMLLoader.java:2661)
                at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2517)
                at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2425)
                at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:89)
                ... 14 more
    

    Caused by: java.lang.ClassNotFoundException: org.idahosif.custom.controls.CopyableLabel at java.lang.ClassLoader.findClass(ClassLoader.java:530) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at javafx.fxml.FXMLLoader.loadTypeForPackage(FXMLLoader.java:2916) at javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:2905) at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2846) ... 19 more

  4. Haraldur Haraldsson

    I get the same error, as soon as I changed from importing using * to the absolute path to my custom component I get the same exception that the custom control isn´t found(using a build from the latest 8.2.0-snapshot). I even have a new issue now when using the * import, my custom library is populated with my custom controls, but scenebuilder still fails to recognize the controls I have added to my scene until I manually add it once to the scene, strange.

  5. Miguel Cardoso

    I have the exact same error as well, SceneBuilder will fail to open if I open the FXML directly from Eclipse (and the FXML uses a custom component), aka loading the FXML through command line: SceneBuilder.exe "PATH_TO_FXML_FILE"

    It will open fine if I load the FXML from SceneBuilder using the File/Open menu or if SceneBuilder is already running. I'm using the new 8.2.0 and it didn't solve the issue. Seems the problem resides in the command line loading, doesn't seem to be loading the installed libraries this way. Most likely it's trying to parse render the FXML before loading the library classes into the class loader. I'm also using Controls FX if that matters.

    I tried changing the app.classpath variable in the cfg file to include my jars, but unless the jars are in a sub-folder of the SceneBuilder folder it doesn't seem to work. Seems absolute paths are not recognized.

  6. Eduard Drenth

    I think it would be good to be able to specify a path in an argument where custom components can be found. This may be a jar or a directory (i.e. target/classes). IDE integration will benefit, especially in projects with custom components under active development.

    At the moment changes in custom components seem to require an update of the imported library.

  7. David MacGibbon

    There is a race condition between loading custom jars in a background thread and opening the fxml files specified in command arguments in the application thread. I don't think I have permissions for a pull request and am not positive my approach isn't going to break something else, but here it is as a patch

    diff --git a/src/main/java/com/oracle/javafx/scenebuilder/app/SceneBuilderApp.java b/src/main/java/com/oracle/javafx/scenebuilder/app/SceneBuilderApp.java --- a/src/main/java/com/oracle/javafx/scenebuilder/app/SceneBuilderApp.java +++ b/src/main/java/com/oracle/javafx/scenebuilder/app/SceneBuilderApp.java @@ -46,6 +46,7 @@ import com.oracle.javafx.scenebuilder.kit.editor.panel.util.dialog.AlertDialog; import com.oracle.javafx.scenebuilder.kit.editor.panel.util.dialog.ErrorDialog; import com.oracle.javafx.scenebuilder.kit.library.BuiltinLibrary; +import com.oracle.javafx.scenebuilder.kit.library.user.LibraryFolderWatcher; import com.oracle.javafx.scenebuilder.kit.library.user.UserLibrary; import com.oracle.javafx.scenebuilder.kit.metadata.Metadata; import com.oracle.javafx.scenebuilder.kit.util.Deprecation; @@ -63,6 +64,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; import java.util.logging.Level; import java.util.logging.Logger; @@ -396,7 +398,7 @@

         userLibrary.explorationCountProperty().addListener((ChangeListener<Number>) (ov, t, t1) -> userLibraryExplorationCountDidChange());
    
    • userLibrary.startWatching();
    •  if (files.isEmpty()) {
           // Creates an empty document
      

      @@ -430,10 +432,14 @@ for (String file : files) { fileObjs.add(new File(file)); } - +
      EditorController.updateNextInitialDirectory(fileObjs.get(0)); // Fix for #45 - Platform.runLater(() -> performOpenFiles(fileObjs, null)); + // Doesn't work for files with custom components + // Platform.runLater(); + CompletableFuture.runAsync( () -> new LibraryFolderWatcher(userLibrary).initAndDiscover())
      + .thenRun( () -> Platform.runLater(() -> performOpenFiles(fileObjs, null))) + .thenRun( () -> userLibrary.startWatching()); }

      Override diff --git a/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java b/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java --- a/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java +++ b/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java @@ -69,7 +69,7 @@ * / -class LibraryFolderWatcher implements Runnable { +public class LibraryFolderWatcher implements Runnable {

      private final UserLibrary library; private final MavenPreferences mavenPreferences; @@ -89,14 +89,22 @@ public void run() {

       try {
      
      • library.updateExplorationCount(0);
      • library.updateExplorationDate(new Date());
      • runDiscovery();
      • // initAndDiscover(); runWatching(); } catch(InterruptedException x) { // Let's stop } } +
      • public Boolean initAndDiscover() {
      • library.updateExplorationCount(0);
      • library.updateExplorationDate(new Date());
      • try {
      • runDiscovery();
      • } catch (InterruptedException e) {
      • }
      • return Boolean.TRUE;
      • }

      /*

  8. Jose Pereda

    Scene Builder 8.3.0 includes a fix to load all the custom controls from any number of jars, so this issue can be closed now.

    David MacGibbon Thanks for your patch, but the fix, inline with how LibraryFolderWatch::exploreAndUpdateLibrary works, didn't require exposing LibraryFolderWatch.

  9. Eduard Drenth

    Some things still don't work....

    double-clicking (from netbeans, but also opening using commandline) several .fxml files in this project: https://github.com/eduarddrenth/iText-GUI causes ClassNotFound.

    I do not want to configure a library manager in SceneBuilder, I want SceneBuilder to find the compiled classses from my project when opening a fxml from that project.

    I guess to achieve this some environment construction (classpath....argument...) is necessary, or is that already there?

  10. Log in to comment