The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
JRuby + Ramaze | Warbler -> Glassfish

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Britt

Posts: 1319
Nickname: jamesbritt
Registered: Apr, 2003

James Britt is a principal in 30 Second Rule, and runs ruby-doc.org and rubyxml.com
JRuby + Ramaze | Warbler -> Glassfish Posted: Nov 11, 2008 3:11 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by James Britt.
Original Post: JRuby + Ramaze | Warbler -> Glassfish
Feed Title: James Britt: Ruby Development
Feed URL: http://feeds.feedburner.com/JamesBritt-Home
Feed Description: James Britt: Playing with better toys
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by James Britt
Latest Posts From James Britt: Ruby Development

Advertisement

I have, of course, been doing much work with JRuby. Most of this has been desktop development with Monkeybars but occasionally I need to do some Web work.

I’m a big fan of Ramaze, mainly because it approaches that sweet spot of strong features with minimum magic. A recent Web app needed to use some Java libraries, and since Ramaze runs fine under JRuby I set out building the site.

I really wanted to deploy to Glassfish as well. Warbler is a terrific gem from Nick Sieger that will bundle up your Rack-based app, including any specified gems, and create a WAR file that can be deployed to a Java app server.

Last time (about a month or so ago) I tried this with a Ramaze app, I was not too successful. Since my application did not have much of a UI to it I opted to write a sparse Rack app instead.

However, my needs changed and I found myself starting to add assorted framework-y features, such as routing and templating, to the site. Rather than reinvent these particular wheels I thought to give Ramaze another shot. Having had to do some amount of trial-and-error experimentation to get even my simple Rack app running smoothly I figure perhaps my earlier frustration with Ramaze was because of my Warbler ignorance.

My renewed attempt didn’t start off so well, but I saw that my JRuby install of Ramaze was bit out of date, so I updated the gem. It looked as though something has been changed in the how Ramaze is dispatching requests because my ealrier errors vanished after the gem update.

A little tweaking of config.ru and config/warble.rb, and presto, it worked.

You can create a bare-bones Ramaze app by running the generator:

$ ramaze --create myapp

This gives you (among other things) start.ru and start.rb.

I renamed start.ru to config.ru and, in config.ru, replaced the require 'start' with most of the contents of start.rb. Here’s what it looks like:

require 'rubygems'
require 'ramaze'
require './controller/init'
require './model/init'
Ramaze.trait[:essentials].delete Ramaze::Adapter
Ramaze.start!
run Ramaze::Adapter::Base

When you start out to warbleize your app, you run (assuming you have already create a config/ directory):

$ warble config

and you get config/warbler.rb. That file is, by default, full of stuff your Ramaze app doesn’t need. Here’s my warble.rb:

Warbler::Config.new do |config|
    config.dirs = %w( controller model  public view)
    config.gems = %w( ramaze )
end

I then ran

$ jruby -S warble

and copied the resulting WAR file to the glassfish autodeploy dir.

And it Just Worked.

I expect no problems adding in my own libraries and the use of a database with an ORM. My first warbled Rack app was doing all that (Sequel with MySQL), and given that Ramaze is loaded and running and handling requests then adding that in should be a non-issue.

Now we can use Ruby’s most elegant Web framework with the fastest Ruby implementation and a robust, full-featured Web application management tool.

Read: JRuby + Ramaze | Warbler -> Glassfish

Topic: Book of Ruby - New Chapter :Symbols Previous Topic   Next Topic Topic: Using routes inside Radius tags

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use