jrubyfx icon indicating copy to clipboard operation
jrubyfx copied to clipboard

fxml load error in jar

Open dangnlg2 opened this issue 8 years ago • 3 comments

OS : OS X El Capitan java version "1.8.0_102" Java(TM) SE Runtime Environment (build 1.8.0_102-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode) Latest version of jrubyfx 1.1.1 (I also tried running it off master as well)

I am trying to launch a jrubyfx GUI in a jar from a Java application, but I am currently running into the following issue as it is having trouble finding my fxml file :

Exception running Application: <NoMethodError: undefined method 'open_stream' for nil:NilClass>

with my fxml_root is specified as :

fxml_root File.dirname(__FILE__)

which is in the same folder as the source code. I have tried to hard code the correct path into fxml_root, I then run into the following issue :

Exception running Application: #<NoMethodError: undefined method '[]' for nil:NilClass> /Applications/MagicDraw/plugins/csrr/csrr_gemjar.jar!/gems/jrubyfx-fxmlloader-0.4.1-java/lib/jrubyfx-fxmlloader.rb:144:in 'rputs' /Applications/MagicDraw/plugins/csrr/csrr_gemjar.jar!/gems/jrubyfx-fxmlloader-0.4.1-java/lib/fxmlloader/real_elts.rb:130:in 'constructValue' /Applications/MagicDraw/plugins/csrr/csrr_gemjar.jar!/gems/jrubyfx-fxmlloader-0.4.1-java/lib/fxmlloader/value_elts.rb:62:in 'processStartElement' /Applications/MagicDraw/plugins/csrr/csrr_gemjar.jar!/gems/jrubyfx-fxmlloader-0.4.1-java/lib/jrubyfx-fxmlloader.rb:440:in 'processStartElement' /Applications/MagicDraw/plugins/csrr/csrr_gemjar.jar!/gems/jrubyfx-fxmlloader-0.4.1-java/lib/jrubyfx-fxmlloader.rb:351:in 'load' /Applications/MagicDraw/plugins/csrr/csrr_gemjar.jar!/gems/jrubyfx-1.1.1-java/lib/jrubyfx/controller.rb:126:in 'load_into' /Applications/MagicDraw/plugins/csrr/csrr_gemjar.jar!/gems/jrubyfx-1.1.1-java/lib/jrubyfx/core_ext/stage.rb:82:in 'fxml' /Applications/MagicDraw/plugins/csrr/csrr_gemjar.jar!/gems/CSRR-0.1.0/lib/CSRR/swap.rb:87:in 'start' org/jruby/RubyBasicObject.java:1594:in 'instance_eval' /Applications/MagicDraw/plugins/csrr/csrr_gemjar.jar!/gems/jrubyfx-1.1.1-java/lib/jrubyfx/module.rb:49:in 'with' /Applications/MagicDraw/plugins/csrr/csrr_gemjar.jar!/gems/CSRR-0.1.0/lib/CSRR/swap.rb:86:in 'start' /Applications/Magic

any help is greatly appreciated.

dangnlg2 avatar Oct 30 '16 06:10 dangnlg2

I'm not at my computer right now so apologies if this is incorrect, but I believe that fxml_root takes a second argument that is the path relative to the root of the jar. I know that resource_root takes that second argument.

griest024 avatar Oct 30 '16 19:10 griest024

@griest024 I don't think so, fxml_root File.dirname(__FILE__) which basically declare that all FXML files are relative to the directory this script is in.

dangnlg2 avatar Oct 30 '16 20:10 dangnlg2

Hey folks,

I just ran into a similar situation. @dangnlg2 Did you find a solution?

When my JRuby Application is a jar, fxml_root always searches for the absolute path and can't find the fxml files that are located inside of the jar. How do you handle this? :-D

bolandross avatar Apr 22 '18 00:04 bolandross