Getting Started With JRuby on Rails for Sun GlassFish Enterprise Server v3 Prelude

Installing JRuby and Required Gems

To develop and deploy Rails applications on the Sun GlassFish, you need to do the following:

  1. Download and install JRuby 1.1.4.

  2. Install Rails on top of your JRuby installation.

  3. Install the GlassFish v3 Gem if you want to deploy your application to a Sun GlassFish instance running inside your JRuby virtual machine.

ProcedureDownloading and Installing JRuby 1.1.4

  1. Go to the JRuby download site.

  2. Download jruby-bin-1.1.4.zip.

  3. Unpack the zip file.

  4. Set your JRUBY_HOME environment variable to the location of your JRuby 1.1.4 installation.

  5. Add <JRUBY_HOME>/bin to your system path so that you can invoke JRuby from anywhere in your directory tree.

ProcedureInstalling Rails on JRuby

  1. Install the Rails Gem:

    jruby —S gem install rails

    You should see the following output, which tells you that six Gems and their documentation have been installed:

    JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    Successfully installed activesupport-2.1.1
    Successfully installed activerecord-2.1.1
    Successfully installed actionpack-2.1.1
    Successfully installed actionmailer-2.1.1
    Successfully installed activeresource-2.1.1
    Successfully installed rails-2.1.1
    6 gems installed
    Installing ri documentation for activesupport-2.1.1...
    Installing ri documentation for activerecord-2.1.1...
    Installing ri documentation for actionpack-2.1.1...
    Installing ri documentation for actionmailer-2.1.1...
    Installing ri documentation for activeresource-2.1.1...
    Installing RDoc documentation for activesupport-2.1.1...
    Installing RDoc documentation for activerecord-2.1.1...
    Installing RDoc documentation for actionpack-2.1.1...
    Installing RDoc documentation for actionmailer-2.1.1...
    Installing RDoc documentation for activeresource-2.1.1...

    The -S parameter that you used to run the command to install Rails tells JRuby to look for the script anywhere in the <JRUBY_HOME> path.

ProcedureInstalling the GlassFish v3 Gem

One of the ways to deploy a Rails application is to deploy it to the Sun GlassFish instance running inside the JRuby virtual machine. To do this, you have to install the GlassFish v3 Gem on top of your JRuby installation:

  1. Run the Gem installer to install the GlassFish v3 Gem:

    jruby -S gem install glassfish

    You should see the following output:

    JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    Successfully installed glassfish-0.3.1-universal-java
    1 gem installedSuccessfully installed glassfish-0.1.2-universal-java
    1 gem installed