History
Back in early 2007 I posted (on this blog even) that I was betting my career on JRuby/JBoss. It turned out OK in the end, but the middle was pretty ugly. A combination of immaturity in JRuby, GoldSpike, our deployment process, and a short development schedule meant that we moved back to plain-old-ruby before we could really prove my JBoss/JRuby theory. Fast forward a few months, Ruby is working fine for WellCare, and Passenger comes out. I loved the concept of Passenger, and WellCare is now happily running Passenger on all of their production sites. In the middle, we used Mongrels behind HAProxy, which is a pretty good solution when you have some processes that may take longer than others. I've since moved on from WellCare, and at my new company we use JRuby on Glassfish exclusively for all of our Rails deployments.
JBoss on Rails
I'm going to write up starting from a fresh Rails 2.1 project, so you can see everything required to deploy. It's really not that much.
Step 1: Download and unzip JBoss AS 5
Step 2: Set the $JBOSS_HOME environment variable to the location of your unzipped JBoss Folder
I downloaded to /Users/briank/Downloads/jboss-5.0.0.CR2 so at the top of my .bash_profile file I added this:
export JBOSS_HOME=/Users/briank/Downloads/jboss-5.0.0.CR2Step 3: Remove the default 'ROOT' context that's installed in JBoss.
We'll remove the default context so that we can deploy to the / context instead of on a subdirectory.
rm -rf /Users/briank/Downloads/jboss-5.0.0.CR2/server/all/deploy/ROOT.warStep 4: Install the jboss-rails deployer
The jboss-rails deployer does JBoss magic and virtually links the deployment directory to your actual deployment location. I keep my Rails apps in ~/NetBeansProjects, so even though the JBoss installation is elsewhere, it will serve the app out of my NetBeansProject/
Download the rails deployer hereUnzip it:
unzip jboss-rails-deployer-1.0.0-beta-1.zipInstall it:
cd jboss-rails-deployer-1.0.0-beta-1cp -R jboss-rails.deployer $JBOSS_HOME/server/all/deployers/Step 5: Install the jboss-rails plugin
./script/plugin install git://github.com/bobmcwhirter/jboss-rails-plugin.git Step 6: Create your database - I'll use mysql for this example
mysqladmin -u root -p create jbosstest_developmentStep 7: Change all references in the plugin folders for the server type.
Several of the rake tasks and other code assumes that you deploy to $JBOSS_HOME/server/all, while others assume $JBOSS_HOME/server/default. Above in step 4, we put our deployer in $JBOSS_HOME/server/all so that's what we're going to use. Search through all the code in the plugin and its rake tasks and make sure they all use /server/all.
Step 8: Install the JDBC gems and adapters for your db installation
rake jboss:rails:jdbc:installStep 9: Deploy your application to JBoss
rake jboss:rails:deployStep 10: Start JBoss
rake jboss:as:runConclusion
I didn't cover any of the advanced features of the plugin or of the concepts behind the jboss-rails integration that Bob's done. One of the most exciting to me is the scheduler process that makes a nice mini-cron out of a directory in your Rails app. I'm all for getting rid of CRON and encapsulating that processing code in my Rails app. The other extremely cool bit of this plugin is the support for Capistrano deployments. Because the integration with JBoss is a virtual symlink to your Rails deployment folder, Bob's included a cap recipe that operates exactly as you'd expect one to. One of the problems with the previous WAR style deployments in my mind has always been the inability to easily move forward and backwards. With JBoss-Rails you get the best of all worlds. I'm really impressed with Bob's work so far and with the attention and commitment that JBoss is bring to Rails deployment.

