views:

183

answers:

1

Hi Nick et al,

I've been having some fun looking at to source code of JRuby-Rack and Rubygems to try to figure out how to solve a

org.jruby.rack.RackInitializationException: no such file to load -- compass

in my rackup script cased by require 'compass'. I'm passing in a custom 'gem.path' as a servlet init parameter and it is being correctly picked up by jruby-rack as far as I can tell by debugging in my rackup script:

ENV['GEM_PATH'] => '/foo/lib/.jruby/gems' (expected)

but rubygems seems to be broken:

Gem.path => file:/foo/lib/jruby-complete-1.4.0.jar!/META-INF/jruby.home/lib/ruby/gems/1.8

I'm not sure why rubygems has not adjusted it's gem_path nor the LOAD_PATH, thus breaking require?

Thanks again, I'm still a newbie at ruby, jruby, rack and sinatra. Any pointers in the right direction appreciated!

Ben

A: 

Hi Ben,

I don't have an answer for you, but I am having a similar problem. I've packaged a custom gem into a jar that is included in my JRuby/Rack/Sinatra web application's classpath. For some reason it's not finding the actual ruby script in the gem even though it's there:

org.jruby.rack.RackInitializationException: JAR entry gems/sinatra-linkedin-auth-0.0.1-java/lib/sinatra/linkedin-auth.rb not found in /Users/bhaidri/code/nextgen-ui/dist/darwin-war/exploded-war/WEB-INF/lib/linkedin-gems-0.0.1.jar

I've checked and re-checked that the ruby file exists in the jar at that exact path that the error is stating it's not found. This was working just fine before, but I changed the package structure of the gem to have my script be located at lib/sinatra/linkedin-auth instead of just lib/linkedin-sinatra-auth.

Any ideas? Your help would be much appreciated!

Thanks, Baq

Baq Haidri
So I figured this out. It turns out that there are some strange issues going on with Tomcat's class loader. It was reading the manifest of the new jar so that it knew the exact path of the Ruby script, but it didn't actually have the jar's classes loaded. It wasn't enough that I redeployed the application, I had to restart Tomcat. Once Tomcat was restarted, everything was in sync.
Baq Haidri