Deploy and Run Rails on GlassFish v2

Install Glassfish v2 from here.

Let's refer to the GlassFish installation directory as $GLASSGISH_ROOT. Getting started guide for Glassfish v2 can be found here

Install JRuby module from Glassfish update center

Run the updatetool to install JRuby on Glassfish module

$GLASSFISH-ROOT/updatecenter/bin/updatetool

Cannot resolve external resource into attachment.

As you can see above, the current version of Glassfish v2 JRuby module is 3.0. Accept the license agreement to install this module. After the successful installation of this module, you would see a new directory jruby created under your GlassFish root directory. A screenshot of the directory structure after having installed the JRuby on GlassFish 3.0 module.

Cannot resolve external resource into attachment.

Note If you had already installed the previous 2.0 module, updatetool would inform that there is an update available. In this case go to the "Available Updates" section and select JRuby on GlassFish 3.0 module and install it.

Rails application deployment

This module comes with Warbler gem. Warbler gem would let you package your Rails or Merb applications as a deployable WAR file. Here is the
description of how you can use Warbler to deploy your
application to GlassFish.

  • Warbler
jruby -S warble

Invoke warlber inside your Rails application to create a deployable war file. This WAR file contains the required JRuby and JRuby-Rack jars
and also required gems.

How to run your application

Standalone Mode

$ jruby -S warble
$ asadmin deploy yourRailsApp.war
  • Access the following URLs in a browser :

http://localhost:8080/yourRailsApp <br>