JDK-8093551 : Files containing classpath relative URL are rejected
  • Type: Bug
  • Component: javafx
  • Sub-Component: tools-scenebuilder
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-11-20
  • Updated: 2015-06-12
  • Resolved: 2014-01-03
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.

To download the current JDK release, click here.
JDK 8
8Fixed
Related Reports
Blocks :  
Duplicate :  
Relates :  
Relates :  
Description
1) Start SB2
2) Open the attached file
=> Scene Builder reports a load error and does open the file

java.io.IOException: javafx.fxml.LoadException: 
/Users/elp/Downloads/classpath-relative-images.fxml:12

	at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:84)
	at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:71)
	at com.oracle.javafx.scenebuilder.kit.editor.EditorController.updateFxomDocument(EditorController.java:1416)
	at com.oracle.javafx.scenebuilder.kit.editor.EditorController.setFxmlTextAndLocation(EditorController.java:455)
	at com.oracle.javafx.scenebuilder.app.DocumentWindowController.loadFromFile(DocumentWindowController.java:209)
	at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performOpenFiles(SceneBuilderApp.java:329)
	at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performOpenFile(SceneBuilderApp.java:303)
	at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performControlAction(SceneBuilderApp.java:103)
	at com.oracle.javafx.scenebuilder.app.menubar.MenuBarController$ApplicationControlActionController.perform(MenuBarController.java:1089)
	at com.oracle.javafx.scenebuilder.app.menubar.MenuBarController.handleOnActionMenu(MenuBarController.java:736)
	at com.oracle.javafx.scenebuilder.app.menubar.MenuBarController.access$300(MenuBarController.java:79)
	at com.oracle.javafx.scenebuilder.app.menubar.MenuBarController$9.handle(MenuBarController.java:729)
	at com.oracle.javafx.scenebuilder.app.menubar.MenuBarController$9.handle(MenuBarController.java:725)
	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
	at javafx.event.Event.fireEvent(Event.java:203)
	at javafx.scene.control.MenuItem.fire(MenuItem.java:462)
	at com.sun.javafx.scene.control.GlobalMenuAdapter$5.handle(GlobalMenuAdapter.java:158)
	at com.sun.javafx.scene.control.GlobalMenuAdapter$5.handle(GlobalMenuAdapter.java:156)
	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
	at javafx.event.Event.fireEvent(Event.java:203)
	at javafx.scene.control.MenuItem.fire(MenuItem.java:462)
	at com.sun.javafx.tk.quantum.GlassSystemMenu$6.action(GlassSystemMenu.java:234)
Caused by: javafx.fxml.LoadException: 
/Users/elp/Downloads/classpath-relative-images.fxml:12

	at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2589)
	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2567)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2397)
	at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:81)
	... 33 more
Caused by: java.lang.IllegalArgumentException: Invalid URL: Invalid URL or resource not found
	at javafx.scene.image.Image.validateUrl(Image.java:1094)
	at javafx.scene.image.Image.<init>(Image.java:671)
	at com.sun.javafx.fxml.builder.JavaFXImageBuilder.build(JavaFXImageBuilder.java:47)
	at com.sun.javafx.fxml.builder.JavaFXImageBuilder.build(JavaFXImageBuilder.java:37)
	at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:752)
	at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2811)
	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2504)
	... 35 more
Caused by: java.lang.IllegalArgumentException: Invalid URL or resource not found
	at javafx.scene.image.Image.validateUrl(Image.java:1086)
	... 41 more

Comments
I reworked my fix in this changeset: changeset: 3189:8ec72f384c60 tag: tip user: eric.le.ponner@oracle.com date: Fri Jan 03 16:16:35 2014 +0100 summary: Second fix for DTL-5986 (Files containing classpath relative URL are rejected).
03-01-2014

Re-opened : my changes destabilized FXOMLoader (see DTL-6208).
02-01-2014

With the following change set, all the issues (but the default property support) are solved: changeset: 3170:76b3930ffd1d tag: tip user: eric.le.ponner@oracle.com date: Mon Dec 30 18:32:20 2013 +0100 summary: Step #2 for DTL-5986 (Files containing classpath relative URL are rejected). SB now setup FXMLLoader so that syntactically incorrect URLs (see #1 et #2 above) are intercepted and replaced by fallback values. It also displays a fallback image when the specified URL does not refer to an existing image file.
30-12-2013

I attached a updated version of the fxml file. This version explicitly mention the "image" properties. This allows to test without falling in DTL-6181 (default property support).
30-12-2013

Some observations: 1) Among the five URL reference in classpath-relative-images.fxml, only the last one is a true "class path relative" one: <Image url="/flower.png" preserveRatio="false" smooth="true" /> <Image url="my/res/flower.png" preserveRatio="false" /> <Image url="http://amos.fr.oracle.com/jmgt/pub/javafx.png" backgroundLoading="false" smooth="false" /> <Image url="file:flower.png" preserveRatio="false" requestedWidth="100.0" smooth="false" /> <Image url="@/flower.png" /> <== CLASSPATH RELATIVE (because @/) 2) Even the class path relative URL support, the file is rejected because of the first two URLs : those ones are incorrect syntactically and cannot be resolved a URL 3) Even if we remove the first two URLs, the file still not load because it declares Image using ImageView's default property. Default property support is another issue tracked by DTL-6181.
30-12-2013