Reputation: 185
I updated to jruby from 9.3.2.0 to 9.3.4.0.
And now when I want to make the war file I get an error.
Any idea?
rvm use jruby-9.3.4.0
jruby -S bundle exec rake assets:clean
jruby -S bundle exec rake assets:precompile
jruby -S warble war
warble aborted!
NoMethodError: undefined method `new_ostruct_member' for No value for 'public' found
/usr/share/rvm/gems/jruby-9.3.4.0/gems/warbler-2.0.5/lib/warbler/traits/war.rb:200:in `method_missing'
/usr/share/rvm/gems/jruby-9.3.4.0/gems/warbler-2.0.5/lib/warbler/traits/war.rb:53:in `default_webxml_config'
/usr/share/rvm/gems/jruby-9.3.4.0/gems/warbler-2.0.5/lib/warbler/traits/war.rb:27:in `before_configure'
/usr/share/rvm/gems/jruby-9.3.4.0/gems/warbler-2.0.5/lib/warbler/traits.rb:29:in `block in before_configure'
/usr/share/rvm/gems/jruby-9.3.4.0/gems/warbler-2.0.5/lib/warbler/traits.rb:29:in `each'
/usr/share/rvm/gems/jruby-9.3.4.0/gems/warbler-2.0.5/lib/warbler/traits.rb:29:in `before_configure'
/usr/share/rvm/gems/jruby-9.3.4.0/gems/warbler-2.0.5/lib/warbler/config.rb:215:in `initialize'
config/warble.rb:19:in `new'
config/warble.rb:19:in `initialize'
/usr/share/rvm/gems/jruby-9.3.4.0/gems/warbler-2.0.5/lib/warbler/task.rb:46:in `eval'
/usr/share/rvm/gems/jruby-9.3.4.0/gems/warbler-2.0.5/lib/warbler/task.rb:46:in `initialize'
/usr/share/rvm/gems/jruby-9.3.4.0/gems/warbler-2.0.5/lib/warbler/application.rb:27:in `new'
/usr/share/rvm/gems/jruby-9.3.4.0/gems/warbler-2.0.5/lib/warbler/application.rb:27:in `load_rakefile'
/usr/share/rvm/gems/jruby-9.3.4.0/gems/warbler-2.0.5/lib/warbler/application.rb:79:in `run'
/usr/share/rvm/gems/jruby-9.3.4.0/gems/warbler-2.0.5/lib/warbler/application.rb:74:in `run'
/usr/share/rvm/gems/jruby-9.3.4.0/gems/warbler-2.0.5/bin/warble:11:in `<main>'
/usr/share/rvm/gems/jruby-9.3.4.0/bin/warble:25:in `load'
/usr/share/rvm/gems/jruby-9.3.4.0/bin/warble:25:in `<main>'
Upvotes: 1
Views: 1228
Reputation: 141
After being annoyed with several pitfalls around warbler I found the time now to pack the needed function into an own Gem. So here it is:
Jarbler: Pack a Ruby app into a self executing jar file including their Gem dependencies
> gem install jarbler
> cd app_dir
> jarble # create the jar file with jRuby runtime
The application can then be started without having a jRuby environment by:
> java -jar AppName.jar
If you want to change the configuration (Defaults are for a Rails app), generate and adjust a config file by
> jarble config
See also: https://github.com/rammpeter/jarbler
Upvotes: 0
Reputation: 31
This was not going to be an answer, but I do not have enough reputation to just make a comment. And this has led to me finding a solution, so it is not all bad!
First the rant. April 2023, a year later, and I am getting this same issue. I am using JRuby 9.4.1, and Warbler version 2.0.5. I can see an issue on GitHub, that was opened January 2022, and is still open. Is Warbler now dead?
The issue seems to be that the new_ostruct_member
method has been made private in JRuby, so one work-around is to bypass that protection.
Paste this code into warble.rb.
class Warbler::Traits::War::WebxmlOpenStruct
def new_ostruct_member(name)
send(:new_ostruct_member!, name)
end
end
Credit: JesseChavez and kovyrin on Github
I also had to add warbler to my Gemfile, which was not necessary previously.
I had to do bundle exec warble
to get it to run, but I did get a .war file at the end of it.
It turns out that (as of April/23) the Github version of Warbler is working, it is just awaiting the gem version, so another approach is to tell Bundler to go to Github.
gem 'warbler', '2.0.5', git: 'https://github.com/jruby/warbler', branch: 'master', platforms: :jruby
Credit: rcrews on Github
Again, I did bundle exec warble
to get it to run, and again I did get a .war file at the end of it.
rcrews also say:
Manually copy *.gemspec into the resulting war:
mkdir WEB-INF && cp myapp.gemspec WEB-INF && zip myapp.war WEB-INF/myapp.gemspec && rm -r WEB-INF
I do not have a gemspec file in my project (should I?), and I have not tried to deploy the .war yet, so no comment on that bit.
Upvotes: 3