I have been hacking on JRuby a bit lately.
I set out to deploy a Ruby on Rails 2.0 application to Tomcat 6 on Monday and it was harder than it should have been.
Some of my angst was no doubt the fact that I'm a newbie, but in case it helps anyone, here are the key bits that made it work for me.
I started with using the Goldspike .war generator. It worked, but was a little clunky.
So then I tried Nick Sieger's Warbler which is much simpler & has more of a Ruby feel to it. I found myself down a rat hole, however in that the Warbler gem comes with JRuby 1.0.1 and that doesn't seem to work with Rails 2.0. If you try to run on it you will be greeted with something like:
INFO: Deploying web application archive your-app-name-here.war
Exception in thread "ObjectPoolManager" java.lang.NoSuchMethodError: org.jruby.RubyHash.op_aset(Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRub
yObject;)Lorg/jruby/runtime/builtin/IRubyObject;
at org.jruby.ext.openssl.X509Name.createX509Name(X509Name.java:98)
at org.jruby.ext.openssl.X509.createX509(X509.java:40)
The documentation is a little bit sparse on this topic & I didn't stumble upon anything in my googling around. The fix is simple - you just have to use a compliant version of JRuby. 1.0.3 works. Here are the steps I took to fix it:
warbler war:debug prints a YAML dump of the current configuration
is definitely useful in tracking stuff down.
Anyway, Warbler is quite simple & useful as it should be.
What's not to like about:
gem install warbler
warbler war
warbler config
warbler war:clean
and warble.rb (config file)?
Note that you can also run it directly under JRuby:
jruby -S gem install warbler
jruby warbler war
jruby warbler config
jruby warbler:clean
Warbler is very tidy. It put's all the generated bits in the tmp dir of your Rails app. This is opposed to Goldspike which puts it all in the WEB-INF dir in the root of your app.
Update I put some of this and more in the JRuby Wiki.