Rack "provides an minimal interface between
webservers supporting Ruby and Ruby frameworks" and JRuby Rack is its logical extension to
Java servlet containers. The latter states "JRuby-Rack supports Rails, Merb, as well
as any Rack-compatible Ruby web framework." While Warbler makes deploying Rails apps to
Glassfish and other Java servlet containers easier than ever, there are scant few (or at
least, none I could find) examples of deploying any old Rack-based Ruby web application to
Glassfish. So here's what I figured out.

Basically, create a war file with a web.xml, jruby-complete-1.1.3.jar, and
jruby-rack-0.9.1.jar. Here's the directory structure I used to build the war:

The rackup parameter is the key, it glues the servlet to your backend
application (I see in the TODO is to allow this script to be defined in a file instead of
in the web.xml). The value of the parameter is a simple Rack-compliant application,
borrowed from this Rack
presentation.

and deploy it to your favorite Java servlet container. Hit it with your browser and you
should see "Hello World!" It's amazing, it just works.

Baby steps! Next to figure out is how to get a full Rack-compliant app, like something
built using Ramaze, running in Glassfish.

Thanks go to this
post, which was very helpful in figuring out what to do.

Visitor comments

On Tue Aug 26th 2008, 8:22am, Chris Schneider posted:

Thanks for the link to my blog (http://www.gittr.com). I haven't gotten
around to writing a post about it, but Nick Sieger (the jruby-rack
maintainer) added a patch that fixed the issue I was running into with
Sinatra. $0 is now set to the .xml file, or something along those lines.