JDK-8093625 : Can not load an FXML that is using fx:root construct
Type:Bug
Component:javafx
Sub-Component:tools-scenebuilder
Affected Version:8
Priority:P2
Status:Closed
Resolution:Fixed
Submitted:2013-10-28
Updated:2015-06-12
Resolved:2013-12-20
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
OK, I filed DTL-6713 for my feature request. Further discussion can take place there.
20-05-2014
@fridolin @Someguy : I think we need to stop hijacking this JIRA which has been fixed.
Please create separate JIRAs for your requests.
@Someguy : you could post your requests/analysis on OTN or open-jfx ;
these are very good places to discuss such a topic.
19-05-2014
An addition to the previous note: Note by the way that it would be fine if the custom controls were treated as "read only" when editing the parent file that imports them. If the user wants to change a custom control, the user can edit that FXML file instead.
16-05-2014
I am not the original poster, but I also have been frustrated by the current requirement that custom controls currently have to be in a separate jar. This was one of the first problems that I hit when trying JavaFX, and it definitely left a bad taste in my mouth. This makes it very difficult to maintain a project that contains many custom controls which are still being developed (if they were all finished and unchanging, it would be less of a problem), and impacts my workflow quite a lot due to the constant separate compilation passes I have to do every time something changes. Also the documentation of the scenebuilder classpath attribute for FXML is rather poor, so it is difficult to figure out how to get this working in the first place.
Please make it possible so that if SceneBuilder loads an FXML file that imports another FXML file containing a custom control, it can recognize the relationship between the files and show the controls described by the second FXML at the location of the import, without requiring that there be compiled Java code (a jar file) to back up the second FXML file. This should at least be possible if a standard JavaFX class is used for the root of the imported file. Of course, Scenebuilder should also still keep the import relationship when writing the files back out.
Basically, the situation for me is that if I have FXML describing a custom control (for, say, a listbox and several buttons to add and remove items from it) that I want to be able to edit FXML files that contain instances of that custom control, and see it in the locations where it appears in those files when editing. There is no reason that I need the Java code for the "real" control for that -- I just need to see the controls that were described by the child FXML files, as if they had been included in the parent file.
Without this feature, using custom controls is quite painful. There is no reason I would normally compile separate JARs for custom controls except for this missing feature in Scenebuilder.
I disagree that this means transforming Scene Builder into a mini IDE, by the way. I just think that it should be capable of understanding that FXML files can import other FXML files. I still intend to use my IDE of choice (IntelliJ IDEA) for maintaining any file type that is not FXML.
Was a JIRA created for this requirement yet?
16-05-2014
>> Does that mean that every custom control has to be in an external jar?
>> Can't I have them in my project structure?
>> I mean the Controls I've written are in my project and I can use them, except in SB.
>> Isn't SB capable of resolving the imports?
Yes, custom components needs to be imported as JAR file in the library.
>> Does this already belong to a new JIRA?
You may create a JIRA for this requirement.
However in the long run this means transforming Scene Builder into a mini IDE.
An alternative is to integrate Scene Builder into existing IDEs.
>> SB is open source right?
Yes
>> Does that mean that anybody can write code for it, or that everyone is allowed to read it only?
Anybody can write code for it
>> What I am asking for is if I can contribute anyhow?
Yes, you can contribute.
The source base available on the web is not in sync.
But that will be fixed soon. Might be worth waiting a bit.
Question : what it your IDE of choice ?
16-05-2014
Thank you for looking into it.
After I packaged them into a jar and put them into the library folder of SB, SB could open it. I also had to put the jar into the buildpath.
This worked at least for some Controls, is there some documentation about how the Contorl has to "look" like that SB is able to import it?
Does that mean that every custom control has to be in an external jar? Can't I have them in my project structure? I mean the Controls I've written are in my project and I can use them, except in SB.
Isn't SB capable of resolving the imports?
Does this already belong to a new JIRA?
SB is open source right? Does that mean that anybody can write code for it, or that everyone is allowed to read it only?
What I am asking for is if I can contribute anyhow?
16-05-2014
I've redone what you have described and it worked for me.
Here is precisely what I did:
1) I downloaded official CustomControl from here:
http://docs.oracle.com/javafx/2/fxml_get_started/CustomControlExample.zip
2) I unzipped and compiled the project with NetBeans 8
3) I dropped CustomControlExample/dist/CustomControlExample.jar in Library panel of Scene Builder
4) Scene Builder discovered one usable component : CustomControl
5) I copied main.fxml as main-patched.fxml and did the following change:
< <?import at.bif4b2.microerp.gui.controls.CustomControl?>
---
> <?import customcontrolexample.CustomControl?>
6) I opened main-patched.fxml with SB : this worked
=> see attached main-patched.fxml
=> see snapshot of the file opened in SB
I suggest that you redo the same steps and try to identify the differences
with your previous experiment. Also try to empty your library folder and add back
all your jars one by one to see if there is any jar conflict.
If you fail to solve your issue, then create a new JIRA and join all the sources
that you are using, including the updated java code of the CustomControlExample
project. I will do another round of investigation.
16-05-2014
I replaced both inlined FXML by attached files (main.fxml and main-short.fxml).
16-05-2014
Yes it does load perfectly, like the other custom controls I wrote.
They are in a package in the project.
Just for validation I imported the custom control example.
See attached main-short.fxml for a shortened version.
Full is in attached main.fxml.
Stacktrace of the shortened version.
java.io.IOException: javafx.fxml.LoadException:
/C:/Users/Username/git/microerp/microerp/src/main/java/at/bif4b2/microerp/gui/main/main.fxml
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:92)
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:80)
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:95)
at com.oracle.javafx.scenebuilder.kit.editor.EditorController.updateFxomDocument(EditorController.java:2370)
at com.oracle.javafx.scenebuilder.kit.editor.EditorController.setFxmlTextAndLocation(EditorController.java:655)
at com.oracle.javafx.scenebuilder.app.DocumentWindowController.loadFromFile(DocumentWindowController.java:386)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performOpenFiles(SceneBuilderApp.java:579)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.handleOpenFilesAction(SceneBuilderApp.java:447)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.handleLaunch(SceneBuilderApp.java:427)
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:371)
at com.sun.javafx.application.LauncherImpl$8.run(LauncherImpl.java:837)
at com.sun.javafx.application.PlatformImpl$7.run(PlatformImpl.java:335)
at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:301)
at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:298)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$6.run(PlatformImpl.java:298)
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.access$300(WinApplication.java:39)
at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
at java.lang.Thread.run(Thread.java:744)
Caused by: javafx.fxml.LoadException:
/C:/Users/Paradies/git/microerp/microerp/src/main/java/at/bif4b2/microerp/gui/main/main.fxml
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2617)
at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2864)
at javafx.fxml.FXMLLoader.processImport(FXMLLoader.java:2708)
at javafx.fxml.FXMLLoader.processProcessingInstruction(FXMLLoader.java:2677)
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)
... 22 more
Caused by: java.lang.ClassNotFoundException: at.bif4b2.microerp.gui.controls.CustomControl
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:2932)
at javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:2921)
at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2862)
... 27 more
16-05-2014
I'm going to investigate and update the bug.
16-05-2014
Can anyone approve this? or is that just me using it wrong?
15-05-2014
- could you provide main.fxml ?
- does main.fxml load fine in your app ?
14-05-2014
I was so happy to read that the final build is available and then this:
Product Version
JavaFX Scene Builder 2.0
Build Information
Version: 2.0-b20, Changeset: 5cac093e5c1f
Date: 2014-03-21 09:29
java.io.IOException: javafx.fxml.LoadException:
/C:/Users/Username/git/microerp/microerp/src/main/java/at/bif4b2/microerp/gui/main/main.fxml
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:92)
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:80)
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:95)
at com.oracle.javafx.scenebuilder.kit.editor.EditorController.updateFxomDocument(EditorController.java:2370)
at com.oracle.javafx.scenebuilder.kit.editor.EditorController.setFxmlTextAndLocation(EditorController.java:655)
at com.oracle.javafx.scenebuilder.app.DocumentWindowController.loadFromFile(DocumentWindowController.java:386)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performOpenFiles(SceneBuilderApp.java:579)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.handleOpenFilesAction(SceneBuilderApp.java:447)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.handleLaunch(SceneBuilderApp.java:427)
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:371)
at com.sun.javafx.application.LauncherImpl$8.run(LauncherImpl.java:837)
at com.sun.javafx.application.PlatformImpl$7.run(PlatformImpl.java:335)
at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:301)
at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:298)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$6.run(PlatformImpl.java:298)
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.access$300(WinApplication.java:39)
at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
at java.lang.Thread.run(Thread.java:744)
Caused by: javafx.fxml.LoadException:
/C:/Users/Paradies/git/microerp/microerp/src/main/java/at/bif4b2/microerp/gui/main/main.fxml
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2617)
at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2864)
at javafx.fxml.FXMLLoader.processImport(FXMLLoader.java:2708)
at javafx.fxml.FXMLLoader.processProcessingInstruction(FXMLLoader.java:2677)
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)
... 22 more
Caused by: java.lang.ClassNotFoundException: at.bif4b2.microerp.gui.controls.CustomControl
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:2932)
at javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:2921)
at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2862)
... 27 more
Why? .. It is the official CustomControl Example.
13-05-2014
Here you go - fresh off the press... http://www.oracle.com/technetwork/java/javase/downloads/sb2download-2177776.html
13-05-2014
I dying to get my hands on that build. Are these changes also available on public? I mean can I build it right now?
08-05-2014
Hi there - I believe the source reflects B14. Since then, we have updated code and fixed many bugs (including this one). All of these fixes will be in the official release of SB2.0 which should be happening any day now.
08-05-2014
I don' t know where to ask. I did ask on Stackoverflow but didn't get a proper answer. I have to use Custom Controls and this Bug affects me because I use SB2 b14. So I went and downloaded the source from http://hg.openjdk.java.net/openjfx/8u-dev/rt and built it on my own. Should the bugs be fixed in this repo?
If not where should i get it?
Where can I ask this more general question usually?
08-05-2014
verified in b16
28-02-2014
SB2 b09 includes JDK 1.8.0-ea-b121 in which RT-34740 is fixed.
When trying to load custom_control.fxml, fx:root construct is now accepted.
However SB breaks on another issue which is tracked by DTL-6181.
This issue is now resolved.
20-12-2013
With SB 2 b08 I get the stack below while opening the filecustom_control.fxml enclosed in http://docs.oracle.com/javafx/2/fxml_get_started/CustomControlExample.zip
This is the same fxml file as the one referred in DTL-5968.
java.io.IOException: javafx.fxml.LoadException: Root hasn't been set. Use method setRoot() before load.
/Users/yjoan/Downloads/CustomControlExample/src/customcontrolexample/custom_control.fxml:10
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:86)
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:72)
at com.oracle.javafx.scenebuilder.kit.editor.EditorController.updateFxomDocument(EditorController.java:1503)
at com.oracle.javafx.scenebuilder.kit.editor.EditorController.setFxmlTextAndLocation(EditorController.java:546)
at com.oracle.javafx.scenebuilder.app.DocumentWindowController.loadFromFile(DocumentWindowController.java:227)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performOpenFiles(SceneBuilderApp.java:426)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.handleOpenFilesAction(SceneBuilderApp.java:292)
at com.oracle.javafx.scenebuilder.app.AppPlatform$MacEventHandler.handleOpenFilesAction(AppPlatform.java:275)
at com.sun.glass.ui.Application.notifyOpenFiles(Application.java:308)
Caused by: javafx.fxml.LoadException: Root hasn't been set. Use method setRoot() before load.
/Users/yjoan/Downloads/CustomControlExample/src/customcontrolexample/custom_control.fxml:10
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2588)
at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:102)
at javafx.fxml.FXMLLoader$RootElement.constructValue(FXMLLoader.java:1303)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:738)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2698)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2502)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2400)
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:83)
... 8 more
05-12-2013
I think this entry reports the same issue as DTL-5968.