I have a simple Sinatra app that I will be hosting in tomcat as a war. Everything works fine when I warble it and run it in tomcat. If I set the Ruby 1.9 flag in my warble config
config.webxml.jruby.compat.version = "1.9"
then the war doesn't run and I get this error in the tomcat logs
INFO: An exception happened during JRuby-Rack startup
no such file to load -- mysinatraapp
--- System
jruby 1.6.5.1 (ruby-1.9.2-p136) (2011-12-27 1bf37c2) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]
Time: 2012-01-16 10:06:32 -0600
Server: Apache Tomcat/7.0.23
jruby.home: file:/apache-tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/jruby-stdlib-1.6.5.1.jar!/META-INF/jruby.home
--- Context Init Parameters:
jruby.compat.version = 1.9
jruby.max.runtimes = 1
jruby.min.runtimes = 1
public.root = /
rack.env = production
--- Backtrace
LoadError: no such file to load -- mysinatraapp
require at org/jruby/RubyKernel.java:1047
require at file:/apache-tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/jruby-stdlib-1.6.5.1.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36
(root) at /apache-tomcat-7.0.23/webapps/ROOT/WEB-INF/config.ru:2
instance_eval at org/jruby/RubyBasicObject.java:1720
initialize at file:/apache-tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/jruby-rack-1.1.3.jar!/vendor/rack-1.3.6/rack/builder.rb:51
(root) at /apache-tomcat-7.0.23/webapps/ROOT/WEB-INF/config.ru:1
the mysinatraapp.rb file is in the war so I don't understand why it can't find it. The app runs fine when just run from the command line in jruby so I don't think it is a compatibility issue with my code and 1.9. Even just removing these lines from the web.xml
<context-param>
<param-name>jruby.compat.version</param-name>
<param-value>1.9</param-value>
</context-param>
will let the app startup fine.
The versions of my jars are jruby-core-1.6.5.1.jar jruby-rack-1.1.3.jar jruby-stdlib-1.6.5.1.jar
I think this can be explained by a subtle change in load path behavior between 1.8 and 1.9 (MRI too, not just JRuby). Witness:
$ jruby -v -rpp -e 'pp $LOAD_PATH'
jruby 1.7.0.dev (ruby-1.8.7-p357) (2012-01-12 0e83d96) (Java HotSpot(TM) Client VM 1.6.0_29) [darwin-i386-java]
["/Users/nicksieger/Projects/ruby/jruby/lib/ruby/site_ruby/1.8",
"/Users/nicksieger/Projects/ruby/jruby/lib/ruby/shared",
"/Users/nicksieger/Projects/ruby/jruby/lib/ruby/1.8",
"."]
$ jruby -v --1.9 -rpp -e 'pp $LOAD_PATH'
jruby 1.7.0.dev (ruby-1.9.3-p6) (2012-01-12 0e83d96) (Java HotSpot(TM) Client VM 1.6.0_29) [darwin-i386-java]
["/Users/nicksieger/Projects/ruby/jruby/lib/ruby/site_ruby/1.9",
"/Users/nicksieger/Projects/ruby/jruby/lib/ruby/shared",
"/Users/nicksieger/Projects/ruby/jruby/lib/ruby/1.9"]
So you'll probably have to explicitly add '.'
or $servlet_context.getRealPath("/WEB-INF")
to the load path inside config.ru.