jruby/warbler — pull request #264 by mgwidmann (2014-05-31 06:42:24+00:00)
Title: JBundler with compiled feature crashes with java.lang.ClassNotFoundException: org.jruby.Main

Anytime JBundler is used with the compiled feature a crash is reported and the war/jar fails to build. A setup like:

```
➜ jbundle_test tree
.
├── Gemfile (Only has 'jbundler' and 'sinatra', but could be any gems)
├── Gemfile.lock
├── Jarfile (Only has 'log4j' but could have more)
├── Jarfile.lock
├── config
│ └── warble.rb (Only change is "compiled" feature is on)
└── config.ru (Dummy sinatra app)
```

When running warbler (either via "warble" or "warble compiled"), shows the following output:

```
Exception in thread "main" java.lang.NoClassDefFoundError: org/jruby/Main
Caused by: java.lang.ClassNotFoundException: org.jruby.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
warble aborted!
Compile failed
/Users/matt/.rvm/gems/jruby-1.7.12/gems/warbler-1.4.2/lib/warbler/jar.rb:62:in `run_javac'
/Users/matt/.rvm/gems/jruby-1.7.12/gems/warbler-1.4.2/lib/warbler/jar.rb:53:in `run_javac'
/Users/matt/.rvm/gems/jruby-1.7.12/gems/warbler-1.4.2/lib/warbler/jar.rb:43:in `compile'
/Users/matt/.rvm/gems/jruby-1.7.12/gems/warbler-1.4.2/lib/warbler/task.rb:109:in `define_compiled_task'
/Users/matt/.rvm/gems/jruby-1.7.12/gems/warbler-1.4.2/lib/warbler/task.rb:88:in `define_main_task'
/Users/matt/.rvm/gems/jruby-1.7.12/gems/warbler-1.4.2/lib/warbler/task.rb:82:in `define_main_task'
/Users/matt/.rvm/gems/jruby-1.7.12/gems/warbler-1.4.2/lib/warbler/application.rb:77:in `run'
/Users/matt/.rvm/gems/jruby-1.7.12/gems/warbler-1.4.2/bin/warble:11:in `(root)'
/Users/matt/.rvm/gems/jruby-1.7.12/bin/warble:1:in `(root)'
/Users/matt/.rvm/gems/jruby-1.7.12/bin/jruby_executable_hooks:15:in `(root)'
Tasks: TOP => war:compiled
```

When the crash occurs, you can see the compile command it tries to run here:

```
java -classpath /Users/matt/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar org.jruby.Main -S jrubyc "config/warble.rb"
```

The JRuby jars are missing from the classpath. The user cannot fix this by adding the JRuby jars to the `config.java_libs` since they are ignored when using the JBundler trait. This happens because the JBundler trait clears the `config.java_libs` and loads the JBundler jars, but doesn't put the JRuby jars back.

This PR exposes the `Warbler::Traits::Jar`'s `default_jar_files` method for the JBundler trait to pull them in after pulling in all the JBundler's jars. If there is a more preferred way to do this I'm all up for it, but this seemed like the simplest change to get this fixed (though it does couple the two traits together).