jrubyjrubyonrailswarblerjruby-rack

Issue loading third party JAR when using Warbler and a downgraded JRuby-Rack?


We're using Warbler to deploy our application to JBoss. The server seems to start fine, but when a request is sent to the application we get the following error:

...
JRuby-Rack startup
    No such file to load -- lib/mylib
....

As you can see it seems to be crashing out when trying to load the mylib.jar, which is Java library we are using in the user.rb class. I've tripled checked that the mylib.jar file exists in the myapp/lib directory and also that it gets successfully packaged by Warbler (it lives in WEB-INF/lib/mylib.jar).

Please Note: I downgraded JRuby-Rack to 1.0.10 after running into the issue detailed here - NoMethodError: relative_url_root when deploying rails app on tomcat. So perhaps the issue has something to do with this?

I'm at a loss as to what's going on. Any ideas?

Other details that might prove useful:

Java Version: 1.6.0_22
JRuby Version: 1.6.5 (ruby-1.9.2-p136)
Ruby Language Level: 1.9

Gemfile:

gem 'rails', '3.1.1'
...
gem 'warbler'
gem 'jruby-rack', '1.0.10'
...

config/warble.rb:

...
config.dirs = %w(app config lib log vendor tmp)
...
config.webxml.jruby.compat.version = "1.9"
...

app/model/user.rb:

require 'java'
require 'lib/mylib.jar'
...

Full Back Trace:

...
14:53:49,552 INFO  [Server] JBoss (MX MicroKernel) [4.3.0.GA_CP01 (build: SVNTag=JBPAPP_4_3_0_GA_CP01 date=200804211657)] Started in 28s:311ms
14:54:33,799 ERROR [STDERR] /usr/local/appserver/jboss4.3/server/ruby/tmp/deploy/tmp4492943940433390521myapp-exp.war/WEB-INF/gems/gems/rack-1.3.5/lib/rack.rb:14 warning: already initialized constant VERSION
14:54:37,614 ERROR [STDERR] /usr/local/appserver/jboss4.3/server/ruby/tmp/deploy/tmp4492943940433390521myapp-exp.war/WEB-INF/gems/gems/jruby-rack-1.0.10/lib/jruby/rack/version.rb:10 warning: already initialized constant VERSION
14:54:41,881 INFO  [ContainerBase] Warning: no min runtimes specified.
14:54:41,888 INFO  [ContainerBase] Warning: no max runtimes specified.
14:54:41,895 INFO  [ContainerBase] An exception happened during JRuby-Rack startup
No such file to load -- lib/mylib
--- System
jruby 1.6.5 (ruby-1.9.2-p136) (2011-10-25 9dcd388) (Java HotSpot(TM) Server VM 1.6.0_22) [linux-i386-java]
Time: 2011-11-28 14:54:41 +0000
Server: JBossWeb/2.0.0.GA_CP05
jruby.home: file:/usr/local/appserver/jboss4.3/server/ruby/tmp/deploy/tmp4492943940433390521myapp-exp.war/WEB-INF/lib/jruby-stdlib-1.6.5.jar!/META-INF/jruby.home

--- Context Init Parameters:
com.sun.faces.injectionProvider = org.jboss.web.jsf.integration.injection.JBossInjectionProvider
jruby.compat.version = 1.9
public.root = /
rails.env = production

--- Backtrace
LoadError: No such file to load -- lib/mylib
...

Output of 'gem list':

$ gem list

*** LOCAL GEMS ***

actionmailer (3.1.1)
actionpack (3.1.1)
activemodel (3.1.1)
activerecord (3.1.1)
activeresource (3.1.1)
activesupport (3.1.1)
arel (2.2.1)
bouncy-castle-java (1.5.0146.1)
builder (3.0.0)
bundler (1.0.21)
capybara (1.1.2)
childprocess (0.2.3, 0.2.2)
ci_reporter (1.6.5)
coffee-rails (3.1.1)
coffee-script (2.2.0)
coffee-script-source (1.1.3)
cucumber (1.1.3)
cucumber-rails (1.2.0)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.2.9)
ffi (1.0.11 java)
gherkin (2.6.8 java)
haml (3.1.3)
haml-rails (0.3.4)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.19, 1.0.18)
jruby-jars (1.6.5)
jruby-launcher (1.0.9 java)
jruby-openssl (0.7.4)
jruby-rack (1.0.10)
json (1.6.2, 1.6.1 java)
json_pure (1.6.2, 1.6.1)
mail (2.3.0)
mime-types (1.17.2)
multi_json (1.0.3)
nokogiri (1.5.0 java)
polyglot (0.3.3)
rack (1.3.5)
rack-cache (1.1)
rack-mount (0.8.3)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.1.1)
railties (3.1.1)
rake (0.9.2.2, 0.8.7)
rcov (0.9.11 java)
rdoc (3.11)
rspec (2.7.0)
rspec-core (2.7.1)
rspec-expectations (2.7.0)
rspec-mocks (2.7.0)
rspec-rails (2.7.0)
rubyzip (0.9.5, 0.9.4)
sass (3.1.10)
sass-rails (3.1.5)
selenium-webdriver (2.13.0)
spork (0.9.0.rc9)
sprockets (2.0.3)
term-ansicolor (1.0.7)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.31)
uglifier (1.1.0)
warbler (1.3.2)
xpath (0.1.4)

Solution

  • How are you requiring your jar.

    if it's

    require 'lib/myjar' 
    

    try changing it to

    require 'myjar' 
    

    and see if that works