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

Discussion in 'Developer Support' started by Furor, Apr 9, 2015.

  1. Furor

    Joined:
    Jun 21, 2014
    Messages:
    344
    Likes Received:
    101
    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:
    [​IMG]
    The location of the built files is D:\Work\Programming\Furor\build\classes\com\runemate\devination

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

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

    Code (Text):
    1. 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
     
  2. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,521
    Likes Received:
    1,039
    @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.
     
  3. Cloud

    Cloud The Developer

    Joined:
    Jul 28, 2013
    Messages:
    2,329
    Likes Received:
    757
    Your getResourceFromStream path is wrong. You need to start the resolution from the package root.
     
  4. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,521
    Likes Received:
    1,039
    Pretty sure this, and many other combinations, have been tried. I did when I tested @Aidden's code at least.
     
  5. Furor

    Joined:
    Jun 21, 2014
    Messages:
    344
    Likes Received:
    101
    I tested

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

    and all other similar combinations
     
  6. SlashnHax

    SlashnHax The Chosen One

    Joined:
    Dec 10, 2014
    Messages:
    2,882
    Likes Received:
    820
    try Devination.class.getResourceAsStream("DeviGUI.fxml")

    Pretty sure the path you supply is meant to be relative to the class you supply.
     
  7. Qosmiof2

    Qosmiof2 Qosidog3 - I write bots not tragedies.

    Joined:
    Aug 5, 2014
    Messages:
    1,577
    Likes Received:
    438
    Still happening...
    --- Double Post Merged, Sep 22, 2015, Original Post Date: Sep 22, 2015 ---
    IF ANYONE IS EXPERIENCING THIS, CHECK YOUR MANIFEST FOR RESOURCES. i Forgot to do that and did confuse myself and other people...

    :)
     
  8. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,521
    Likes Received:
    1,039
    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.
     
    Qosmiof2 likes this.
  9. Furor

    Joined:
    Jun 21, 2014
    Messages:
    344
    Likes Received:
    101
    @Arbiter I'm still having this exact same issue on this same script bot, 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 (Text):
    1.             final Parent root = loader.load(Resources.getAsStream("/com/runemate/devination/DeviGUI.fxml"));
    2.  
    [​IMG]

    Code (Text):
    1.         <resource>com/runemate/devination/gui/DeviGUI.fxml</resource>
    2.  
    I've tried all sorts of combinations.
     
  10. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,521
    Likes Received:
    1,039
    Try removing the leading slash from the argument for Resources.getAsStream.
    --- Double Post Merged, Nov 11, 2015, Original Post Date: Nov 11, 2015 ---
    It's also missing the gui package in it. :p
    --- Double Post Merged, Nov 11, 2015 ---
    Looks like you're including one as a resource and calling for the other in your code.
    --- Double Post Merged, Nov 11, 2015 ---
    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.
     

Share This Page

Loading...