neurogami

Mind-bending application development 
« Back to blog

Ramaze and Rack with JRuby: Some examples

 

I have a production app running Ramaze on top of JRuby, deployed to a Glassfish v2 server.  It's been happily spinning along for about 8 months now.

I've been looking to move it off its current server to another machine, so I tried to get it running with current versions of Ramaze, JRuby, etc.

I had some initial bad luck, with assorted cryptic errors and the need to change configuration files.  The libs in question (jruby-rack, warbler, glassfish) have assorted docs and examples that talk quite a bit about Rails, but nothing about Ramaze, and relatively little about plain old Rack. (Sun, the people behind Glassfish, seems to think Ruby and Rails are the same thing.)

I wanted to have some simple example apps so that I could pinpoint what works and what doesn't.

There is code and some notes up on Github:

http://github.com/Neurogami/gf-rack-ramaze-experiments/tree/master

I have dead-simple Ramaze and Rack apps set to run either as Warbler-generated war files, or  run via the glassfish gem command-line call.

I've successfully war'ed up Rack and Ramaze apps and deployed to a glassfish v2 server. 

However, at the moment it looks as though the glassfish gem does not properly fill in for rackup; whereas a config.ru file can typically have assorted Rack middleware, the glassfish gem just breaks when encountering "use Rack::Foo" or "run SomeThing".  Basically, it has no idea what the 'use' or 'run' methods are.

You can use it for really simple Rack apps (no middleware, just a proc), but Ramaze fails with assorted errors over the lack of values for various rack env keys (such as rack.run_once, which are otherwise fine when using rackup, with or without JRuby).

Loading mentions Retweet
Posted by neurogami 

Comments (2)

Aug 13, 2009
arungupta said...
Thanks James for the wonderful post!

We do know the difference between Ruby and Rails. There are extensive Rack/Sinatra notes at: http://blogs.sun.com/arungupta/entry/rails_conf_2009_day_1, all of which were tried on JRuby/GlassFish :)

I'll take a look at your experiments.

Aug 13, 2009
neurogami said...
The problem with the Sinatra examples is that the glassfish gem automagically knows what to do with Sinatra apps; no config.ru file is needed or shown.

Despite the glassfish gem being touted as able to run any rack-based framework, it has built-in hooks for a specific set of frameworks, and the rack aspect seems lost because there are no good examples of general "rack-based framework" usage.

The massive value of Rack is that it can help us do away with needing framework-specific hooks. Ideally, a tool such as the glassfish gem would have nothing that was framework specific. All one would need is a valid config.ru file and it would Just Work. (There's a similar issue in warbler, where there is baked-in smarts for a select set of frameworks, and you have to explicitly tell it you are not using Rails. Again, the ideal approach would be to assume :rack unless otherwise specified. )

Perhaps this is the long-term goal for glassfish, but right now it does not properly handle standard config.ru files (even discounting the need for the grizzly gems).

In any event I thought it would be helpful to have some Ramze and Rack examples of what worked and what didn't, then start asking for help it getting it all running nicely.

Leave a comment...

 
To leave a comment on this posterous, please login by clicking one of the following.
Posterous-login     twitter