jruby/jruby-rack — Issue #89: Broken 1.9-mode deploys due to load path modifications
Author: headius
Created: 2012-01-31 14:00:56+00:00
State: open

There appears to be a problem with recent jruby-rack that's causing a complete failure to deploy 1.9-mode applications. The full output is here: https://gist.github.com/1710589

The problem happens during boot, when the 'yaml' library is loaded. It attempts to require 'psych', which should load lib/ruby/1.9/psych.rb and related files. However, because of an apparent load path misconfiguration, it only finds the internal 'psych.jar' extension (which doesn't exist as a jar...we just use that name...it's PsychLibrary in JRuby).

I added some writes to a file to show loaded features and load path at the point of failure (inside yaml.rb). At that point, loaded features ($") contains psych.jar but none of the psych .rb files, which define the "to_yaml" method in question. The load path contains the following four stdlib-related entries:

```
classpath:/META-INF/jruby.home/lib/ruby/site_ruby/1.9
classpath:/META-INF/jruby.home/lib/ruby/site_ruby/shared
classpath:/META-INF/jruby.home/lib/ruby/site_ruby/1.8
classpath:/META-INF/jruby.home/lib/ruby/1.9
```

I believe this is the source of the problem. These paths do not appear to be handled as expected in JRuby. If I make a similar modification at the command line, I get a similar failure:

```

jruby-1.6.6@debug ~/projects/jruby/debug/war2/WEB-INF/tmp $ java -Djruby.debug.loadService=true -cp /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/jruby-jars-1.6.5.1/lib/jruby-core-1.6.5.1.jar:/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/jruby-jars-1.6.5.1/lib/jruby-stdlib-1.6.5.1.jar org.jruby.Main --1.9 --disable-gems -e "\$:.replace(['classpath:META-INF/jruby.home/lib/ruby/site_ruby/1.9', 'classpath:META-INF/jruby.home/lib/ruby/1.9']); require 'psych'; p \$\""
LoadService: trying builtinLib: thread.jar
LoadService: found builtinLib: thread.jar
LoadService: trying builtinLib: enumerator.class
LoadService: trying builtinLib: enumerator.rb
LoadService: trying resourceFromJarURLWithLoadPath: /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/jruby-jars-1.6.5.1/lib/jruby-stdlib-1.6.5.1.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.9/enumerator.class
LoadService: trying resourceFromJarURLWithLoadPath: /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/jruby-jars-1.6.5.1/lib/jruby-stdlib-1.6.5.1.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.9/enumerator.rb
LoadService: trying resourceFromJarURLWithLoadPath: /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/jruby-jars-1.6.5.1/lib/jruby-stdlib-1.6.5.1.jar!/META-INF/jruby.home/lib/ruby/site_ruby/shared/enumerator.class
LoadService: trying resourceFromJarURLWithLoadPath: /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/jruby-jars-1.6.5.1/lib/jruby-stdlib-1.6.5.1.jar!/META-INF/jruby.home/lib/ruby/site_ruby/shared/enumerator.rb
LoadService: trying resourceFromJarURLWithLoadPath: /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/jruby-jars-1.6.5.1/lib/jruby-stdlib-1.6.5.1.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/enumerator.class
LoadService: trying resourceFromJarURLWithLoadPath: /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/jruby-jars-1.6.5.1/lib/jruby-stdlib-1.6.5.1.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/enumerator.rb
LoadService: trying resourceFromJarURLWithLoadPath: /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/jruby-jars-1.6.5.1/lib/jruby-stdlib-1.6.5.1.jar!/META-INF/jruby.home/lib/ruby/1.9/enumerator.class
LoadService: trying resourceFromJarURLWithLoadPath: /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/jruby-jars-1.6.5.1/lib/jruby-stdlib-1.6.5.1.jar!/META-INF/jruby.home/lib/ruby/1.9/enumerator.rb
LoadService: trying builtinLib: enumerator.jar
LoadService: found builtinLib: enumerator.jar
LoadService: trying builtinLib: generator_internal.class
LoadService: trying builtinLib: generator_internal.rb
LoadService: found builtinLib: generator_internal.rb
LoadService: trying builtinLib: thread.class
LoadService: trying builtinLib: thread.rb
LoadService: found builtinLib: thread.rb
LoadService: trying builtinLib: psych.class
LoadService: trying builtinLib: psych.rb
LoadService: trying resourceFromLoadPath: '/Users/headius/projects/jruby/debug/war2/WEB-INF/tmp/classpath:META-INF/jruby.home/lib/ruby/site_ruby/1.9/psych.class' false false
LoadService: trying resourceFromLoadPath: '/Users/headius/projects/jruby/debug/war2/WEB-INF/tmp/classpath:META-INF/jruby.home/lib/ruby/site_ruby/1.9/psych.rb' false false
LoadService: trying resourceFromLoadPath: '/Users/headius/projects/jruby/debug/war2/WEB-INF/tmp/classpath:META-INF/jruby.home/lib/ruby/1.9/psych.class' false false
LoadService: trying resourceFromLoadPath: '/Users/headius/projects/jruby/debug/war2/WEB-INF/tmp/classpath:META-INF/jruby.home/lib/ruby/1.9/psych.rb' false false
LoadService: trying builtinLib: psych.jar
LoadService: found builtinLib: psych.jar
["thread.jar", "enumerator.jar", "generator_internal.rb", "thread.rb", "psych.jar"]
```

Notice that the classpath: paths are getting prefixed with my current dir, which makes them fail to resolve any of the jarred-up files.

Reproducing this issue should be easy. I tested on Glassfish, and a user that initiated the JRuby bug (http://jira.codehaus.org/browse/JRUBY-6397) is using JBoss.

* Generate a new Rails app
* Configure warbler to deploy in 1.9 mode
* Deploy and hit the app

The app will fail to boot with the error reported here.

This is a pretty critical issue, since it means nobody can deploy WARed up applications in 1.9 mode right now. I'm assigning @kares to look at it since he's had most of the recent commits, some of them load path-related.

Help me Karol Bucek...you're my only hope!