I am trying to write some code in ruby (using jruby) to be compiled to java bytecode with jrubyc and deployed to a remote machine where it will be run on the JVM (no ruby available there).
Everything works fine as long as I am happy to stick with the standard jruby library. As explained on the jruby website, I simply copy the jruby-complete.jar library to the remote machine and include it in the classpath at runtime. I fire my compiled script and it works: cool!
The problems start when I need some other libraries (typically rubygems) to run my script.
I am aware of cool stuff like rawr, -which I successfully tested- to put together all you need in a single package.
However that is not the solution I am looking for: I will have many small scripts to run independently and I don't want each of them to grow to at least 10 MB just because I insanely include the jruby-complete.jar in each of them.
What I would like is to compile a .jar for each of the libraries that I will need to use, put all of them in a common folder on the remote machine and include them at runtime in the classpath when I run my compiled jruby scripts on the JVM.
This said, I tried to follow the instructions here: http://blog.nicksieger.com/articles/2009/01/10/jruby-1-1-6-gems-in-a-jar
I tried exactly the example shown there, with the "chronic" gem. Going step by step:
Write a two lines test script, saving it as testt.rb:
require 'chronic'
Chronic.parse('tomorrow')
Compile with: jrubyc testt.rb
I get the following error:
Exception in thread "main" file:/Users/ave2/NetBeansProjects/jrubywatir/lib/jruby-complete.jar!/METAINF/jruby.home/lib/ruby/site_ruby/shared/builtin/core_ext/symbol.rb:1:in `const_missing': uninitialized constant Chronic (NameError)
from testt.rb:2
...internal jruby stack elided...
from Module.const_missing(testt.rb:2)
from (unknown).(unknown)(:1)
I really don't understand what I am doing wrong, and I am totally stuck on this. I am a noob in Ruby, much more used to Python: don't miss a chance to convert an infidel! :-) Thanks.
From what I can tell, it looks like you're not doing anything wrong, and you've probably hit a bug. Can you try your example with a more recent release (http://jruby.org/download) and if you still see the issue, create a bug at http://bugs.jruby.org/ ? Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With