Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

JavaFX: java.lang.NullPointer Exception: inputStream is null - Loading resources

Joined
Jun 21, 2014
Messages
350
I'm trying to load a JavaFX .fxml file in my bot but I can't determine what is the problem, it's either when trying to load the file in the manifest or when opening the file in a stream.

Here's some information:

Here's what the folder looks like in the IDE:
BfouBS0.png

The location of the built files is D:\Work\Programming\Furor\build\classes\com\runemate\devination

Code:
main-class>com.runemate.devination.Devination</main-class>
This is how I load the main file in the manifest

Code:
<resource>com/runemate/devination/DeviGUI.fxml</resource>
This is how I'm trying to load the file in the manifest

Code:
final Parent root = loader.load(Devination.class.getResourceAsStream("/Furor/src/com/runemate/devination/DeviGUI.fxml"));
This is how I try to load the file in the code, I've tried all sorts of combinations but no luck

I've tried so many combinations, but to no luck
 
Mod Automation
Joined
Jul 26, 2013
Messages
3,044
@Cloud I tried to resolve this a while back for @Aidden, but never came up with a solution. Perhaps you could discuss the details with him. Interestingly enough, the same code works just fine through the Bot Store. There's a good chance this isn't a bug, but just requires some user education. Maybe a tutorial is in order.
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
Your getResourceFromStream path is wrong. You need to start the resolution from the package root.
 
Joined
Jun 21, 2014
Messages
350
Pretty sure this, and many other combinations, have been tried. I did when I tested @Aidden's code at least.
I tested

final Parent root = loader.load(Devination.class.getResourceAsStream("/com/runemate/devination/DeviGUI.fxml"));

and all other similar combinations
 
Joined
Dec 10, 2014
Messages
3,255
try Devination.class.getResourceAsStream("DeviGUI.fxml")

Pretty sure the path you supply is meant to be relative to the class you supply.
 
I've been called a god before.
Joined
Aug 5, 2014
Messages
3,212
Still happening...
 
IF ANYONE IS EXPERIENCING THIS, CHECK YOUR MANIFEST FOR RESOURCES. i Forgot to do that and did confuse myself and other people...

:)
 
Mod Automation
Joined
Jul 26, 2013
Messages
3,044
For future reference here are the two steps to fix 99% of these issues:
  1. Make sure the resource is mapped in your manifest XML.
  2. Use the Resources class in the API to load the desired resources using absolute path.
If all else fails move the resource to the root package and try loading it from there.
 
Joined
Jun 21, 2014
Messages
350
@Arbiter I'm still having this exact same issue on this same script, I've switched to loading from the absolute path via the API, used an absolute path in my manifest as well as placing the resource in the root path and I simply cannot get it to work.

Code:
            final Parent root = loader.load(Resources.getAsStream("/com/runemate/devination/DeviGUI.fxml"));

KnIzuwj.png


Code:
        <resource>com/runemate/devination/gui/DeviGUI.fxml</resource>

I've tried all sorts of combinations.
 
Mod Automation
Joined
Jul 26, 2013
Messages
3,044
@Arbiter I'm still having this exact same issue on this same script, I've switched to loading from the absolute path via the API, used an absolute path in my manifest as well as placing the resource in the root path and I simply cannot get it to work.

Code:
            final Parent root = loader.load(Resources.getAsStream("/com/runemate/devination/DeviGUI.fxml"));

KnIzuwj.png


Code:
        <resource>com/runemate/devination/gui/DeviGUI.fxml</resource>

I've tried all sorts of combinations.
Try removing the leading slash from the argument for Resources.getAsStream.
 
It's also missing the gui package in it. :p
 
Looks like you're including one as a resource and calling for the other in your code.
 
Also looks like neither DeviGUI.fxml is in your SVN (thus the red color). Right click -> Subversion -> Add to VCS and then commit. Then use an SVN browser, such as our web based one RuneMate - USVN, to ensure it's in there.
 
Top