Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error launching JrubyFX app, trouble loading fxml_root #4156

Open
dangnlg2 opened this issue Sep 14, 2016 · 12 comments
Open

Error launching JrubyFX app, trouble loading fxml_root #4156

dangnlg2 opened this issue Sep 14, 2016 · 12 comments

Comments

@dangnlg2
Copy link

dangnlg2 commented Sep 14, 2016

Environment

Environments:
Jruby version 1.7.26
warbler 1.4.8
Mac OSX

Issues:

get_fxml_loader doesn't seem to work in jar.

jar was packaged using warbler.

Code:

require 'jrubyfx'
require 'tempfile'

fxml_root File.dirname(__FILE__)

class CircuitMapApp < JRubyFX::Application

    def start(stage)
        with(stage, title: "CIRCUIT MAP", width: 600, height: 350) do
          fxml CircuitMapController
          show
        end
    end
end

Expected Behavior

launch application from a jar using JrubyFX

Actual Behavior

crashes in the attempt to do the file join because is nil although fxml_root was specified in the app.

Launching the app works outside of the jar , where there's protection in place to assure that root_dir has fxml_root .

here's the stack trace :

Exception running Application:

NoMethodError: undefined method `open_stream' for nil:NilClass

/Applications/MagicDraw/plugins/CSRR/CSRR_gems.jar!/gems/jrubyfx-fxmlloader-0.4.1-java/lib/jrubyfx-fxmlloader.rb:296:in `load'
/Applications/MagicDraw/plugins/CSRR/CSRR_gems.jar!/gems/jrubyfx-1.1.1-java/lib/jrubyfx/controller.rb:123:in `load_into'
/Applications/MagicDraw/plugins/CSRR/CSRR_gems.jar!/gems/jrubyfx-1.1.1-java/lib/jrubyfx/core_ext/stage.rb:82:in `fxml'
/Applications/MagicDraw/plugins/CSRR/CSRR_gems.jar!/gems/CSRR-0.0.0/lib/plugin/circuitmap.rb:73:in `start'
org/jruby/RubyBasicObject.java:1533:in `instance_eval'
/Applications/MagicDraw/plugins/CSRR/CSRR_gems.jar!/gems/jrubyfx-1.1.1-java/lib/jrubyfx/module.rb:49:in `with'
/Applications/MagicDraw/plugins/CSRR/CSRR_gems.jar!/gems/CSRR-0.0.0/lib/plugin/circuitmap.rb:72:in `start'
/Applications/MagicDraw/plugins/CSRR/CSRR_gems.jar!/gems/jrubyfx-1.1.1-java/lib/jrubyfx/java_fx_impl.rb:119:in `launch_app_after_platform'
org/jruby/gen/InterfaceImpl1495460524.gen:13:in `run'
LAUNCHED 143
2016-09-14 01:58:00,444 [AWT-EventQueue-0] INFO  GENERAL - Close Project task started.
@headius
Copy link
Member

headius commented Sep 14, 2016

Is your app available anywhere we could try it? If not, perhaps you can reproduce with a smaller app we can run? It sounds like the steps might be fairly simple.

@dangnlg2
Copy link
Author

unfortunately no,it is a MagicDraw plugin and I'm trying to launch it from MagicDraw's menu.

@headius
Copy link
Member

headius commented Sep 14, 2016

Ok, we'll have to struggle through this way then :-)

We need to get a better backtrace...the one you provided is truncated at load because LoadError wraps the original exception. Normally you'd get the original exception by passing -d to JRuby, but in this case I think the right way is to pass -Djruby.cli.debug=true to whatever JVM is launching the jar.

Give that a shot and see if we get better output.

@headius
Copy link
Member

headius commented Sep 14, 2016

Oh wait, I may be mistaken...I think this is actually the load method that tries to read fxml. I'll check the code and see if I have any theories.

@headius
Copy link
Member

headius commented Sep 14, 2016

Failing line is here: https://github.com/byteit101/JRubyFX-FXMLLoader/blob/master/lib/jrubyfx-fxmlloader.rb#L296

It's trying to open_stream against a URL passed into the loader's constructor here: https://github.com/byteit101/JRubyFX-FXMLLoader/blob/master/lib/jrubyfx-fxmlloader.rb#L267

I think the line setting up the loader is here: https://github.com/jruby/jrubyfx/blob/master/lib/jrubyfx/controller.rb#L348

So the problem most likely lies within get_fxml_location and the logic it uses to determine a location.

However, looking at jrubyfx master, it appears that @byteit101 tried to fix some jar issues earlier this year in jruby/jrubyfx@8862d0f. I do not know if this commit made it into a release or not. If it did, we've got more work to do.

@headius
Copy link
Member

headius commented Sep 14, 2016

Oh a detail I missed: it does not seem possible for the current version of get_fxml_location to produce a nil location...so I suspect @byteit101's fix is not in jrubyfx 1.1.1.

@headius
Copy link
Member

headius commented Sep 14, 2016

Ahh...indeed...the last release was in Nov 2014, and this fix came in Jan 2015 (not 2016 as I implied above).

@dangnlg2 Either you can try to run off a master build of jrubyfx, or you can wait until we get a release out (would be @enebo or @byteit101, not me).

@dangnlg2
Copy link
Author

@headius That was very helpful to know, thank you for looking into it.

Can you show me how to run it off the master build?

Do I just clone this repo and run it from there as a jar?

@headius
Copy link
Member

headius commented Sep 14, 2016

@dangnlg2 I'm not sure, actually :-) Hopefully @byteit101 or @enebo can help.

@headius
Copy link
Member

headius commented Sep 14, 2016

Oh! One thing you could do is just try to apply that same patch to whatever your local copy of jrubyfx is.

@dangnlg2
Copy link
Author

dangnlg2 commented Sep 15, 2016

After running it off master and editing the fxml_root path, I am currently getting a permission access issue.

I'm not sure as to why I am getting this issue. Any idea?

Stack trace :

LAUNCHED 143
Exception running Application:
Errno::EACCES: Permission denied - /CSRR

org/jruby/RubyDir.java:443:in mkdir' /var/folders/4y/v6zdtbw17j7glbr3r7wnbqkw0000gn/T/jruby1594567722804287529extract/jruby-stdlib-complete-1.7.16.1.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:247:infu_mkdir'
/var/folders/4y/v6zdtbw17j7glbr3r7wnbqkw0000gn/T/jruby1594567722804287529extract/jruby-stdlib-complete-1.7.16.1.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:221:in mkdir_p' org/jruby/RubyArray.java:1693:inreverse_each'
/var/folders/4y/v6zdtbw17j7glbr3r7wnbqkw0000gn/T/jruby1594567722804287529extract/jruby-stdlib-complete-1.7.16.1.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:219:in mkdir_p' org/jruby/RubyArray.java:1613:ineach'
/var/folders/4y/v6zdtbw17j7glbr3r7wnbqkw0000gn/T/jruby1594567722804287529extract/jruby-stdlib-complete-1.7.16.1.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:205:in mkdir_p' /Applications/MagicDraw/plugins/CSRR/CSRR_gems.jar!/gems/jrubyfx-fxmlloader-0.4.1-java/lib/fxmlloader/fxml_jit_info.rb:64:ininitialize'
/Applications/MagicDraw/plugins/CSRR/CSRR_gems.jar!/gems/jrubyfx-fxmlloader-0.4.1-java/lib/jrubyfx-fxmlloader.rb:294:in load' /Applications/MagicDraw/plugins/CSRR/CSRR_gems.jar!/gems/jrubyfx-1.1.1-java/lib/jrubyfx/controller.rb:129:inload_into'
/Applications/MagicDraw/plugins/CSRR/CSRR_gems.jar!/gems/jrubyfx-1.1.1-java/lib/jrubyfx/core_ext/stage.rb:82:in fxml' /Applications/MagicDraw/plugins/CSRR/CSRR_gems.jar!/gems/CSRR-0.0.0/lib/plugin/circuitmap.rb:76:instart'
org/jruby/RubyBasicObject.java:1533:in instance_eval' /Applications/MagicDraw/plugins/CSRR/CSRR_gems.jar!/gems/jrubyfx-1.1.1-java/lib/jrubyfx/module.rb:49:inwith'
/Applications/MagicDraw/plugins/CSRR/CSRR_gems.jar!/gems/CSRR-0.0.0/lib/plugin/

@dangnlg2
Copy link
Author

@headius Do you have any idea as to what is causing this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants