0

I am trying to use the HBase Java API with Trinidad in a Rails 3.2 Application. Everything works fine when I put all jar files into Rails.root/lib/jars, which is Trinidad's preferred *.jar-folder.

When I try to separate the jar files from the project via a java.rb initializer file (in config/initializers) it won't work correctly. (With WebBrick, everything works smoothly, but we cannot use it in production.)

java.rb:

require 'java'

Dir['/var/apps/jars/*.jar'].each do |jar|
  require jar
end

Trinidad starts without a problem, but as soon as a request hits a controller using the HBaseConfiguration Class the following error is thrown:

Java::JavaLang::RuntimeException (hbase-default.xml file seems to be for and old version of HBase (null), this version is 0.90.6-cdh3u4):

It seems that hbase-default.xml is bundled inside the hbase-0.90.6-cdh3u4.jar file, but cannot be found by the HBaseConfiguration Class.

Do you have ideas on how to fix this?

kares
  • 7,076
  • 1
  • 28
  • 38
Jasper
  • 1,971
  • 19
  • 34

1 Answers1

1

this probably won't be the "correct" answer but you can customize Trinidad's jars path to point to /var/apps/jars for your application (using the command line or with the trinidad.yml config)

than adjust the initializer so when it runs within a java web-server it does not load the jars (Webrick is a ruby web-server that happen to run fine with JRuby as it's writen in pure Ruby) e.g. :

Dir['/var/apps/jars/*.jar'].each do |jar|
  require jar
end unless defined?($servlet_context)

as for the issue you're having it's most likely hbase.jar and/or hadoop.jar specific (class-loaders will look different in a simple jruby application and a jruby servlet application), it's hard to tell without some more info such as a stack trace, jar versions and most importantly some understanding of hadoop's configuration / resource loading.

kares
  • 7,076
  • 1
  • 28
  • 38