JBoss on Rails

September 22nd, 2008

Tomorrow is my first real status update call with my boss, Sacha Labourey.  I’ve been anxious to deliver something, to prove I hadn’t gone completely pudding-brained during my tenure as management.

This morning, it all finally came together in a pleasing fashion, causing me to hoot and holler loud enough to scare the cats and probably some cows.

I’ve just pushed an ugly-but-working deployer targeting JBoss-AS 5.0.0.CR2 (the latest and greatest!)

It’s not very consumable at this point, as it’s just a deployer, not a nice Rails plugin with a set of Rake tasks.  Heck, it doesn’t even undeploy yet.

But adding the deployer to your server’s deployers/ directory allows you symlink live RAILS_ROOTs into your deploy/ directory, and be running on JBoss.

Live.  In-situ.  Edit your controllers or views as you like, and your changes are immediately reflected in the running instance.  Just like with ./script/server.  It does not even have to redeploy your app.  The rails framework is handling the magic reloading.

It’s taken me some time to dig through the innards of JBoss-Microcontainer, and a few false starts, but I finally figured out a super simple deployment process.

I’d previously been trying to manipulate a RAILS_ROOT into a synthetic Java WAR archive, and shoe-horn things around that.  But I have the freedom to go lower than that, so the jboss-rails deployer just sets up a Catalina context appropriately, without regard to WEB-INF or other non-Rails stuff.  There’s no need for that cruft.  Likewise, I can directly control and manipulate the classpath, so the RAILS_ROOT does not even have to have any JRuby bits in it.

The example application (src/test/ballast) is a virgin rails app with ActiveRecord disabled so I don’t have to deal with database-driver gems just yet.

Once deployed, a Rails app looks like pretty much any other web-app.  The jboss.rails.deployment domain contains deployment objects for each rails app.  And jboss.web contains all the webby bits floating around.

I need to go  back and remove the dead-end code I’ve left in my wake, and update the tests I’d disabled while in a coding flury (bad Bob!)  I plan to put together an easy-to-consume plugin gem which contains an nicely-configured AS along with the jboss-rails deployer pre-installed, along with rake tasks to start/stop AS, and deploy your app.  I’d also like to give clustering a whirl, and see what we can do.

It’s been an excellent 3 weeks back as an engineer.

8 Responses to “JBoss on Rails”

  1. 1 peter royal
    September 22nd, 2008 at 11:33 am

    wow, awesome! good work!

  2. 2 Max Andersen
    September 22nd, 2008 at 2:04 pm

    Cool - can’t wait to get some humanoid explanation of how to use microcontainer for things like this ;)

  3. 3 anjan bacchu
    September 22nd, 2008 at 2:38 pm

    hi there,

    good work.

    When can we expect a download of the Minimalist Jboss AS along with your work together in a bundle ?

    BR,
    ~A

  4. 4 Michael Neale
    September 22nd, 2008 at 7:46 pm

    Nice work bob !

  5. 5 Ales Justin
    September 23rd, 2008 at 3:21 am

    Few comments on the current code :-)

    RailsEnvironmentParsingDeployer
    - no need to additionally put parsed metadata as attachment
    - abstract parsing deployer already does that for you; as managed object
    - attachments are searched hierarchically
    - unit.getAttachment finds the first one in hierarchy

    RailsStructure
    - in case of error, cleanup context info you created

    RailsAppDeployer
    - i guess more VFS based abstract deployer could be used :-)
    - as discussed, mbeans –> mc beans
    - missing ServiceMetaData (BeanMetaData after move to MC beans) output

    ;-)

  6. 6 Bob McWhirter
    September 23rd, 2008 at 8:51 am

    @Ales–

    Thanks for the code-review. I’ll dive through it all again and neaten it up.

    I’ll definitely adjust from MBeans to MC beans.

    Thanks!

  7. 7 Sacha Labourey
    September 23rd, 2008 at 8:51 am

    That is the first time I have the chance to be updated on somebody’s status BEFORE the update call takes place.

    Actually, when I called Bob this morning (his time) and queried about news, the first thing he told me was “Didn’t you see my blog?…”. See? Isn’t that a great strategy? He found a way to make ME feel guilty for not doing my homework i.e. not reading his blog. I just subscribed to your RSS feed Bob, so this won’t happen anymore, I promise ;)

    Oh, but more importantly: GREAT WORK BOB! I would have been slightly sad to see you provide some kind of hack on top of the MC, and the fact that you’ve spend time and energy learning about the MC to use its proper interfaces, is great. Thanks!

    Onward,

    sacha

  8. [...] McWhirter has been playing around with Ruby and JBoss - here’s his first progress report. The start of something cool I’m [...]

Leave a Reply