Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » resourcefile not found at runtime(resource file works in preview but not when the program is run)
resourcefile not found at runtime [message #1173588] Wed, 06 November 2013 16:23 Go to next message
Jackson McCann is currently offline Jackson McCannFriend
Messages: 4
Registered: November 2013
Junior Member
I specify a resource file in my .fxgraph file and use it to set the text on some buttons. This works fine in the previewer but when I run my code it fails with the following error.

No resources specified.
/M:/Workspace/EACobolTool/bin/uk/co/adminre/eacoboltool/EACobolTool.fxml:21
  at javafx.fxml.FXMLLoader$Element.processPropertyAttribute(Unknown Source)
  at javafx.fxml.FXMLLoader$Element.processInstancePropertyAttributes(Unknown Source)
  at javafx.fxml.FXMLLoader$ValueElement.processEndElement(Unknown Source)
  at javafx.fxml.FXMLLoader.processEndElement(Unknown Source)
  at javafx.fxml.FXMLLoader.load(Unknown Source)
  at javafx.fxml.FXMLLoader.load(Unknown Source)
  at javafx.fxml.FXMLLoader.load(Unknown Source)
  at javafx.fxml.FXMLLoader.load(Unknown Source)
  at javafx.fxml.FXMLLoader.load(Unknown Source)
  at javafx.fxml.FXMLLoader.load(Unknown Source)
  at javafx.fxml.FXMLLoader.load(Unknown Source)
  at uk.co.adminre.eacoboltool.Main.start(Main.java:14)
  at com.sun.javafx.application.LauncherImpl$5.run(Unknown Source)
  at com.sun.javafx.application.PlatformImpl$5.run(Unknown Source)
  at com.sun.javafx.application.PlatformImpl$4$1.run(Unknown Source)
  at com.sun.javafx.application.PlatformImpl$4$1.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.application.PlatformImpl$4.run(Unknown Source)
  at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
  at com.sun.glass.ui.win.WinApplication$3$1.run(Unknown Source)
  at java.lang.Thread.run(Unknown Source)

javafx.fxml.LoadException: No resources specified.
	at javafx.fxml.FXMLLoader$Element.processPropertyAttribute(Unknown Source)
	at javafx.fxml.FXMLLoader$Element.processInstancePropertyAttributes(Unknown Source)
	at javafx.fxml.FXMLLoader$ValueElement.processEndElement(Unknown Source)
	at javafx.fxml.FXMLLoader.processEndElement(Unknown Source)
	at javafx.fxml.FXMLLoader.load(Unknown Source)
	at javafx.fxml.FXMLLoader.load(Unknown Source)
	at javafx.fxml.FXMLLoader.load(Unknown Source)
	at javafx.fxml.FXMLLoader.load(Unknown Source)
	at javafx.fxml.FXMLLoader.load(Unknown Source)
	at javafx.fxml.FXMLLoader.load(Unknown Source)
	at javafx.fxml.FXMLLoader.load(Unknown Source)
	at uk.co.adminre.eacoboltool.Main.start(Main.java:14)
	at com.sun.javafx.application.LauncherImpl$5.run(Unknown Source)
	at com.sun.javafx.application.PlatformImpl$5.run(Unknown Source)
	at com.sun.javafx.application.PlatformImpl$4$1.run(Unknown Source)
	at com.sun.javafx.application.PlatformImpl$4$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.application.PlatformImpl$4.run(Unknown Source)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
	at com.sun.glass.ui.win.WinApplication$3$1.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)


Removing the reference to the resource file and putting the button text into the .fxml file allows the application to run. Where should the resource file be placed so that it's found at runtime? Do I have to add some code to the application to get it picked up?

Jackson

[Updated on: Wed, 06 November 2013 16:24]

Report message to a moderator

Re: resourcefile not found at runtime [message #1173595 is a reply to message #1173588] Wed, 06 November 2013 16:30 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Well you need to adjust the FXMLLoader code to pass on a ResourceBundle.

In case you use the static FXMLLoader.load() method you need to use the
one who takes URL, ResourceBundle.

Tom

On 06.11.13 17:23, Jackson McCann wrote:
> I specify a resource file in my .fxgraph file and use it to set the text
> on some buttons. This works fine in the previewer but when I run my
> code it fails with the following error.
> No resources specified.
> /M:/Workspace/EACobolTool/bin/uk/co/adminre/eacoboltool/EACobolTool.fxml:21
> at javafx.fxml.FXMLLoader$Element.processPropertyAttribute(Unknown Source)
> at
> javafx.fxml.FXMLLoader$Element.processInstancePropertyAttributes(Unknown
> Source)
> at javafx.fxml.FXMLLoader$ValueElement.processEndElement(Unknown Source)
> at javafx.fxml.FXMLLoader.processEndElement(Unknown Source)
> at javafx.fxml.FXMLLoader.load(Unknown Source)
> at javafx.fxml.FXMLLoader.load(Unknown Source)
> at javafx.fxml.FXMLLoader.load(Unknown Source)
> at javafx.fxml.FXMLLoader.load(Unknown Source)
> at javafx.fxml.FXMLLoader.load(Unknown Source)
> at javafx.fxml.FXMLLoader.load(Unknown Source)
> at javafx.fxml.FXMLLoader.load(Unknown Source)
> at uk.co.adminre.eacoboltool.Main.start(Main.java:14)
> at com.sun.javafx.application.LauncherImpl$5.run(Unknown Source)
> at com.sun.javafx.application.PlatformImpl$5.run(Unknown Source)
> at com.sun.javafx.application.PlatformImpl$4$1.run(Unknown Source)
> at com.sun.javafx.application.PlatformImpl$4$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at com.sun.javafx.application.PlatformImpl$4.run(Unknown Source)
> at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
> at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
> at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
> at com.sun.glass.ui.win.WinApplication$3$1.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
>
> javafx.fxml.LoadException: No resources specified.
> at javafx.fxml.FXMLLoader$Element.processPropertyAttribute(Unknown
> Source)
> at
> javafx.fxml.FXMLLoader$Element.processInstancePropertyAttributes(Unknown
> Source)
> at javafx.fxml.FXMLLoader$ValueElement.processEndElement(Unknown
> Source)
> at javafx.fxml.FXMLLoader.processEndElement(Unknown Source)
> at javafx.fxml.FXMLLoader.load(Unknown Source)
> at javafx.fxml.FXMLLoader.load(Unknown Source)
> at javafx.fxml.FXMLLoader.load(Unknown Source)
> at javafx.fxml.FXMLLoader.load(Unknown Source)
> at javafx.fxml.FXMLLoader.load(Unknown Source)
> at javafx.fxml.FXMLLoader.load(Unknown Source)
> at javafx.fxml.FXMLLoader.load(Unknown Source)
> at uk.co.adminre.eacoboltool.Main.start(Main.java:14)
> at com.sun.javafx.application.LauncherImpl$5.run(Unknown Source)
> at com.sun.javafx.application.PlatformImpl$5.run(Unknown Source)
> at com.sun.javafx.application.PlatformImpl$4$1.run(Unknown Source)
> at com.sun.javafx.application.PlatformImpl$4$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at com.sun.javafx.application.PlatformImpl$4.run(Unknown Source)
> at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
> at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
> at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
> at com.sun.glass.ui.win.WinApplication$3$1.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
>
>
> Removing the reference to the resource file and putting the button text
> into the .fxml file allows the application to run. Where should the
> resource file be placed so that it's found at runtime? Do I have to add
> some code to the application to get it picked up?
>
> Jackson
>
>
Re: resourcefile not found at runtime [message #1174733 is a reply to message #1173595] Thu, 07 November 2013 09:30 Go to previous messageGo to next message
Jackson McCann is currently offline Jackson McCannFriend
Messages: 4
Registered: November 2013
Junior Member
Thanks for the quick reply. The following change fixed the problem:

ResourceBundle resources = ResourceBundle.getBundle("uk.co.mycompany.mypackage.messages") ;
BorderPane root = (BorderPane)FXMLLoader.load(getClass().getResource("MyScreen.fxml"), resources);
Scene scene = new Scene(root,400,400);


This loads the resources in the file messages.properties that is located in the uk.co.mycompany.mypackage directory.

I also tried the following (based on the answer to the question "javafx 2 and internationalization" on StackOverflow (had to remove link as I haven't 5 posts yet)) that resulted in the following working code.


FXMLLoader fxmlLoader = new FXMLLoader();
ResourceBundle resources = ResourceBundle.getBundle("uk.co.mycompany.mypackage.messages") ;
fxmlLoader.setResources(resources) ;
BorderPane root = (BorderPane) fxmlLoader.load(this.getClass().getResource("MyScreen.fxml").openStream());
Scene scene = new Scene(root,400,400);

[Updated on: Thu, 07 November 2013 09:30]

Report message to a moderator

Re: resourcefile not found at runtime [message #1174920 is a reply to message #1174733] Thu, 07 November 2013 11:52 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
[...]

>
>
> FXMLLoader fxmlLoader = new FXMLLoader();
> ResourceBundle resources =
> ResourceBundle.getBundle("uk.co.mycompany.mypackage.messages") ;
> fxmlLoader.setResources(resources) ;
> BorderPane root = (BorderPane)
> fxmlLoader.load(this.getClass().getResource("MyScreen.fxml").openStream());
> Scene scene = new Scene(root,400,400);
>

Someone should fix this code to:
a) close the stream
b) setting the location (else e.g. resource loading won't work
appropriately, sub-xml loading will be broken, ...)

Tom
Previous Topic:menu mnemonics
Next Topic:JDK8b115 has a major regression skip it!
Goto Forum:
  


Current Time: Tue Apr 23 09:23:41 GMT 2024

Powered by FUDForum. Page generated in 0.03618 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top