Problem wrapping Voldemort client Java class into JRuby class: dependencies not loading

I am trying to use the Voldemort http://project-voldemort.com/ Java
client
from JRuby by wrapping the
voldemort.clienthttp://github.com/voldemort/voldemort/tree/master/src/java/voldemort/client/
Java
class in a JRuby module VoldemortClient. This is on OS X with the JRuby
downloaded from jruby.org.

See:

http://project-voldemort.com/quickstart.php
http://project-voldemort.com/javadoc/client/

The code is here: voldemort_client.rb · GitHub

@calavera on Twitter was able to run this code, but no matter what I do
I
get this error when I require the voldemort_client lib:

/Users/rjurney//jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/core_ext/module.rb:53:in
import': cannot link Java class voldemort.client.SocketStoreClientFactory, probable missing dependency: org/jdom/Content (NameError) from ./lib/voldemort_client.rb:10 from ./lib/voldemort_client.rb:2:in require’
from ./test.rb:2

This also happens in jirb. I have tried manually importing the class
‘org.jdom.Content’ and it has no effect. It seems that
voldemort’s dependencies are not actually being imported. I have tried
requiring each of them manually, to their absolute path - but it has no
effect.

Help! Thanks,
Russ

Source to lib/voldemort_client.rb:

require ‘java’
PATH_TO_VOLDEMORT = ‘/Users/rjurney/voldemort/’

require File.expand_path(‘dist/voldemort-0.81.jar’, PATH_TO_VOLDEMORT)
Dir[File.expand_path(‘lib/*.jar’, PATH_TO_VOLDEMORT)].each {|jar|
require
jar}

module VoldemortClient
import ‘org.jdom.Content’
import ‘voldemort.client.ClientConfig’;
import ‘voldemort.client.SocketStoreClientFactory’;
import ‘voldemort.client.StoreClient’;
import ‘voldemort.client.StoreClientFactory’;
import ‘voldemort.versioning.Versioned’;

alternately, use the #import method

import “voldemort.client”
end

I resolved the problem by specifying all jars in my CLASSPATH, but I
don’t
understand why I had to do so.

Russell J.
http://twitter.com/rjurney
http://linkedin.com/in/russelljurney

On Jul 5, 2010, at 4:16 PM, Russell J. [email protected]
wrote:

I am trying to use the Voldemort http://project-voldemort.com/ Java
client
from JRuby by wrapping the
voldemort.clienthttp://github.com/voldemort/voldemort/tree/master/src/java/voldemort/client/
Java
class in a JRuby module VoldemortClient. This is on OS X with the JRuby
downloaded from jruby.org.

See:

http://project-voldemort.com/quickstart.php
http://project-voldemort.com/javadoc/client/

The code is here: voldemort_client.rb · GitHub

@calavera on Twitter was able to run this code, but no matter what I do
I
get this error when I require the voldemort_client lib:

/Users/rjurney//jruby-1.5.1/lib/ruby/site_ruby/shared/builtin/javasupport/core_ext/module.rb:53:in
import': cannot link Java class voldemort.client.SocketStoreClientFactory, probable missing dependency: org/jdom/Content (NameError) from ./lib/voldemort_client.rb:10 from ./lib/voldemort_client.rb:2:in require’
from ./test.rb:2

This also happens in jirb. I have tried manually importing the class
‘org.jdom.Content’ and it has no effect. It seems that
voldemort’s dependencies are not actually being imported. I have tried
requiring each of them manually, to their absolute path - but it has no
effect.

Help! Thanks,
Russ

Source to lib/voldemort_client.rb:

require ‘java’
PATH_TO_VOLDEMORT = ‘/Users/rjurney/voldemort/’

require File.expand_path(‘dist/voldemort-0.81.jar’, PATH_TO_VOLDEMORT)
Dir[File.expand_path(‘lib/*.jar’, PATH_TO_VOLDEMORT)].each {|jar|
require
jar}

module VoldemortClient
import ‘org.jdom.Content’
import ‘voldemort.client.ClientConfig’;
import ‘voldemort.client.SocketStoreClientFactory’;
import ‘voldemort.client.StoreClient’;
import ‘voldemort.client.StoreClientFactory’;
import ‘voldemort.versioning.Versioned’;

alternately, use the #import method

import “voldemort.client”
end

Well it’s a workaround but actually I don’t understand why it didn’t
work
either. I tested the script in my ubuntu machine and it also worked
fine.