Posts Tagged ‘jruby’

Mac(OSX) Jruby and Rails 2.2 — Part 2

Running webrick isn’t doing what we want… How about Tomcat? Or maybe Glassfish? Well I have heard that glassfish is VERY EASY, lets checkit out…

Step 1:
~$ sudo jruby -S gem install glassfish
Successfully installed glassfish-0.9.0-universal-java
1 gem installed
Installing ri documentation for glassfish-0.9.0-universal-java…
Installing RDoc documentation for glassfish-0.9.0-universal-java…

DONE… no I’m serious… THAT WAS IT!!!

Lets start the server:

~$ jruby -S glassfish_rails myapp
Nov 17, 2008 7:21:23 PM com.sun.enterprise.glassfish.bootstrap.ASMain main
INFO: Launching GlassFish on Apache Felix OSGi platform
Nov 17, 2008 7:21:23 PM com.sun.enterprise.glassfish.bootstrap.ASMainOSGi findDerbyClient
INFO: Cannot find javadb client jar file, jdbc driver not available

Now I can access the rails app at http://localhost:3000/


Here is some more information about the glassfish gem:

-c, –contextroot PATH: change the context root (default: ‘/’)
-p, –port PORT: change server port (default: 3000)
-e, –environment ENV: change rails environment (default: development)
-n –runtimes NUMBER: Number of JRuby runtimes to crete initially
–runtimes-min NUMBER: Minimum JRuby runtimes to crete
–runtimes-max NUMBER: Maximum number of JRuby runtimes to crete
APPLICATION_PATH (optional): Path to the application to be run (default:

This is almost too easy for a development environment…

THIS IS NOT A BENCHMARK BUT even so here is the info…

My laptop with a test app I have and seed data installed thin 1.0 and Glassfish…

With threading:
Requests per second: Thin 10 [#/sec]
Requests per second: Glassfish 14 [#/sec]

Without threading:
Requests per second: Thin 3 [#/sec]
Requests per second: Glassfish 2.6 [#/sec]

🙂 Not what I was hoping for …

Mac(OSX) Jruby and Rails 2.2

Not Sure why but I wanted to try JRuby and Rails(2.2) new threads…

These are the steps I used to get a application on my mac running with Rails 2.2 and JRuby 1.1.3(I used ports to install JRuby thats why 1.1.3).

Here are the steps:

– First Install JRuby .. # sudo port install jruby

– Fix an annoying warning .. # sudo jruby -S gem install jruby-openssl

– Install rails .. # sudo jruby -S gem install rails

– Install the database connector .. # sudo jruby -S gem install activerecord-jdbc-adapter

– Upgrade the gem environment .. # sudo jruby -S gem update

– Install latest RubyGems (Rails 2.2 Needs 1.3.1 or higher.. ) .. # sudo jruby -S gem install rubygems-update

– Now you have to force install the update .. # sudo jruby -S update_rubygems

– Install Rails 2.2.1 .. # jruby -S gem install rails -s

# jruby -S rails myapp
# cd myapp
# vi config/database.yml

adapter: jdbc
driver: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost/testapp_development
username: root

# vi config/environment.rb
Add this code:

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), ‘boot’)
if RUBY_PLATFORM =~ /java/
require ‘rubygems’

# jruby script/server
=> Booting WEBrick…
=> Rails 2.2.1 application started on
=> Ctrl-C to shutdown server; call with –help for options
[2008-11-17 16:40:34] INFO WEBrick 1.3.1
[2008-11-17 16:40:34] INFO ruby 1.8.6 (2008-11-17) [java]
[2008-11-17 16:40:34] INFO WEBrick::HTTPServer#start: pid=13484 port=4000