Bug 691659 - libguestfs fails to run under JRuby 1.6.0
libguestfs fails to run under JRuby 1.6.0
Product: Virtualization Tools
Classification: Community
Component: libguestfs (Show other bugs)
x86_64 Linux
unspecified Severity unspecified
: ---
: ---
Assigned To: Richard W.M. Jones
Depends On: 561484 723191
  Show dependency treegraph
Reported: 2011-03-29 03:55 EDT by Marek Goldmann
Modified: 2012-05-03 09:53 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-05-03 09:53:39 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Sample Ruby script (1.71 KB, text/x-ruby-script)
2011-03-29 03:55 EDT, Marek Goldmann
no flags Details
Strace output for create_disk.rb (45.84 KB, application/octet-stream)
2011-03-29 03:56 EDT, Marek Goldmann
no flags Details
JRuby program (786 bytes, text/plain)
2011-07-19 17:32 EDT, Richard W.M. Jones
no flags Details

  None (edit)
Description Marek Goldmann 2011-03-29 03:55:58 EDT
Created attachment 488364 [details]
Sample Ruby script

Description of problem:

With JRuby 1.6.0 we have now experimental support for C extensions. Unfortunately guestfs doesn't work. To start work with JRuby and libguestfs do:

1. Download latest JRuby (http://www.jruby.org/)
2. Copy Ruby bindings from your Fedora 14 installation:

cp /usr/lib/ruby/site_ruby/1.8/guestfs.rb $JRUBY_HOME/lib/ruby/site_ruby/1.8/
cp /usr/lib64/ruby/site_ruby/1.8/x86_64-linux/_guestfs.so $JRUBY_HOME/lib/native/x86_64-Linux/

3. Launch irb:

[goldmann@work tmp]$ jruby -J-Xmx1024m -I$JRUBY_HOME/lib/native/x86_64-Linux/ -S irb
irb(main):001:0> require 'guestfs'
=> true
irb(main):002:0> g = Guestfs::create
=> #<Guestfs::Guestfs:0x3458213c>
irb(main):003:0> g.set_trace(1)
Fatal: unknown type 0x22
	from (irb):3:in `evaluate'
	from org/jruby/RubyKernel.java:1087:in `eval'
	from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:158:in `eval_input'
	from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:271:in `signal_status'
	from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:155:in `eval_input'
	from org/jruby/RubyKernel.java:1417:in `loop'
	from org/jruby/RubyKernel.java:1190:in `catch'
	from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:154:in `eval_input'
	from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:71:in `start'
	from org/jruby/RubyKernel.java:1190:in `catch'
	from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:70:in `start'
	from /home/goldmann/boxgrinder-torquebox/jruby/bin/jirb:13:in `(root)'

Version-Release number of selected component (if applicable):

Comment 1 Marek Goldmann 2011-03-29 03:56:33 EDT
Created attachment 488365 [details]
Strace output for create_disk.rb
Comment 2 Richard W.M. Jones 2011-04-12 13:16:30 EDT
From reading about this, it seems that JRuby has some
support for C extensions, but that it is known to be

There seem to be two possible ways forward:

(1) Use the actual Java libguestfs bindings instead.  This
seems to be the standard reply, eg:

(2) Ask upstream JRuby developers if there is anything we
can do to make the Ruby extensions friendlier towards JRuby
or the JVM.
Comment 3 Richard W.M. Jones 2011-07-18 15:13:58 EDT
Now we have jruby in Rawhide, we could actually test this and
debug it ...
Comment 4 Marek Goldmann 2011-07-19 02:23:01 EDT
(In reply to comment #3)
> Now we have jruby in Rawhide, we could actually test this and
> debug it ...

Yes, I'll try to reproduce it on Rawhide and get back to you with my results.
Comment 5 Marek Goldmann 2011-07-19 06:45:37 EDT
With latest jruby-1.6.2-2.fc16.noarch which is in Rawhide I got:

$ jruby -J-Xmx1024m -I/usr/share/jruby/lib/native/ -S irb
/usr/bin/build-classpath: error: Could not find jffi Java extension for this JVM
/usr/bin/build-classpath: error: Could not find jruby-yecht Java extension for this JVM
/usr/bin/build-classpath: error: Some specified jars were not found
irb(main):001:0> require 'guestfs'
LoadError: load error: _guestfs -- java.lang.NoClassDefFoundError: com/kenai/jffi/Library
from org/jruby/RubyKernel.java:1038:in `require'
from /usr/share/jruby/lib/ruby/site_ruby/1.8/guestfs.rb:18:in `(root)'
from org/jruby/RubyKernel.java:1038:in `require'
from /usr/share/jruby/lib/ruby/site_ruby/1.8/guestfs.rb:1:in `evaluate'
from org/jruby/RubyKernel.java:1088:in `eval'
from /usr/share/jruby/lib/ruby/1.8/irb.rb:158:in `eval_input'
from /usr/share/jruby/lib/ruby/1.8/irb.rb:271:in `signal_status'
from /usr/share/jruby/lib/ruby/1.8/irb.rb:155:in `eval_input'
from org/jruby/RubyKernel.java:1419:in `loop'
from org/jruby/RubyKernel.java:1191:in `catch'
from /usr/share/jruby/lib/ruby/1.8/irb.rb:154:in `eval_input'
from /usr/share/jruby/lib/ruby/1.8/irb.rb:71:in `start'
from org/jruby/RubyKernel.java:1191:in `catch'
from /usr/share/jruby/lib/ruby/1.8/irb.rb:70:in `start'
from /usr/share/jruby/bin/jirb:13:in `(root)'

It seems that ffi lib couldn't be found and seems to be a JRuby packaging issue to me.
Comment 6 Richard W.M. Jones 2011-07-19 17:12:16 EDT
It works for me OK if you use the Java bindings via JRuby.

I will attach a test program to demonstrate.
Comment 7 Richard W.M. Jones 2011-07-19 17:32:48 EDT
Created attachment 513884 [details]
JRuby program

The attached program has been tested with JRuby in
Fedora Rawhide.  Note that it also requires the very
latest libguestfs (>= 1.11.20).
Comment 8 Richard W.M. Jones 2012-05-03 09:39:30 EDT
I think the recommended approach (for jruby) is to
use the Java classes.  I have checked that this works.
If this is sufficient for you I would like to close
this bug.
Comment 9 Marek Goldmann 2012-05-03 09:43:38 EDT
Rich, That's fine. When I'll have more info on this in the future, I'll add to this ticket. Feel free to close it.
Comment 10 Richard W.M. Jones 2012-05-03 09:53:39 EDT
Closing as per comment 9.

Note You need to log in before you can comment on or make changes to this bug.