Sun GlassFish Enterprise Server v3 Scripting Framework Guide

Chapter 1 Using JRuby on Rails With Sun GlassFish Enterprise Server

This tutorial shows you how to get started using JRuby on Rails on the Sun GlassFishTM Enterprise Server v3.

The following topics are addressed here:

Introduction to JRuby and Rails on Sun GlassFish Enterprise Server

This section gives you an overview of JRuby and Rails on the Sun GlassFish Enterprise Server by explaining the following concepts:

What Is Ruby on Rails ?

Ruby is an interpreted, dynamically-typed, object-oriented programming language. It has a simple, natural syntax that enables developers to create applications quickly and easily. It also includes the easy-to-use RubyGems packaging utility for customizing a Ruby installation with additional plug-ins.

Rails is a web application framework that leverages the simplicity of Ruby and eliminates much of the repetition and configuration required in other programming environments. With Rails, you can create database-backed web applications, complete with models and tables, by running a few one-line commands.

To learn more about Ruby on Rails, see Ruby on Rails.

What Is JRuby ?

JRuby is a JavaTM implementation of the Ruby interpreter. While retaining many of the popular characteristics of Ruby, such as dynamic-typing, JRuby is integrated with the Java platform. With JRuby on Rails, you get the simplicity and productivity offered by Ruby and Rails and the power of the Java platform offered by JRuby, thereby giving you many benefits as a Rails developer, including the following:

To learn more about JRuby, see JRuby.

JRuby on Rails, the Sun GlassFish Enterprise Server v3, and the GlassFish v3 Gem

Developing and deploying your Rails application on the Sun GlassFish Enterprise Server gives you the following advantages over using a typical web server used for running Rails applications:

You have the following options for deploying a Rails application on GlassFish Server:

A Gem is a Ruby package that contains a library or an application. In fact, Rails itself is a Gem that is installed on JRuby. For more details on GlassFish v3 Gem, see GlassFish v3 Gem.

Installation and Configuration of JRuby

    To develop and deploy Rails applications on the Enterprise Server, do the following:

  1. Download and install JRuby.

  2. Install Rails on top of your JRuby installation.

You can perform the above tasks by installing JRuby on your Enterprise Server instance in one of the following ways:

ProcedureTo Install JRuby and Rails from Update Center

JRuby and other associated Gems are now available as IPS packages from Update Center. By downloading them using the Update Tool, you can install them directly on your Enterprise Server.

For information about the Update Tool, see Sun GlassFish Enterprise Server v3 Installation Guide.

  1. Start the update tool:

    as-install/bin/updatetool

  2. From the Update Tool, choose the following packages from Available Add-Ons:

    • JRuby on GlassFish which contains JRuby 1.3.1

    • JRuby Gems which contains Rails 2.3.2, Warbler, jdbc-mysql, and activerecord-jdbcmysql-adapter packages.

  3. Click Install, which will install the packages on your Enterprise Server instance.

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

    export JRUBY_HOME=/jruby-install-location

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

    export PATH=$PATH:$JRUBY_HOME/bin

  6. On the Windows operating system, use the following commands for Steps 4 and 5:

    set JRUBY_HOME=C:\jruby-install-location

    set PATH=%JRUBY_HOME%\bin;%PATH%


    Note –

    If GlassFish v3 JRuby IPS package was installed using update tool, then there is no need to set the jruby.home system property


ProcedureTo Install JRuby as Standalone

To install your own JRuby instance as standalone, use the following procedure.

  1. Go to JRuby download site JRuby Download Site.

  2. Download jruby-bin-1.3.1.zip or the latest version.

  3. Unpack the zip file:

    unzip jruby-bin-1.3.1.zip

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

    export JRUBY_HOME=/jruby-install-location

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

    export PATH=$PATH:$JRUBY_HOME/bin

  6. If you want to use this JRuby installation with your Enterprise Server, use the following steps to inform and configure Enterprise Server instance with the location of the JRuby installation:

    1. Start your GlassFish installation:

      asadmin start-domain

    2. Set JRuby home:

      asadmin configure-jruby-container --jruby.home=/jruby-install-location

ProcedureTo Install Rails Gem on JRuby

If you installed your JRuby as a standalone instance, you also need to install the required Rails and other Gems on it. To install Rails, use the following procedure.

  1. Install the Rails Gem:

    jruby —S gem install rails

    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. With this command, JRuby and required Gems are installed on JRuby.

Enterprise Server v3 JRuby Container Configuration

The Sun GlassFish Enterprise Server v3 provides the following ways to configure the installed JRuby container.

Configuring JRuby Container Through Asadmin CLI

The asadmin CLI now provides options to configure the JRuby container. The command execution is reflected in changes to the JRuby container configuration section of the domain.xml file which makes them persistent.

The following JRuby container properties can be configured through the asdmin command.

configure-jruby-container [--help]
     [--monitoring={false|true}]
     [--jruby-home jruby-home]
     [--jruby-runtime jruby-runtime]
     [--jruby-runtime-min jruby-runtime-min]
     [--jruby-runtime-max jruby-runtime-max]
     [--show={true|false}]

Use the following asadmin command syntax to configure these values:

asadmin configure-jruby-container --<property>=<value>

For example, the following command is used to set the JRuby home if JRuby instance is installed as standalone:

asadmin configure-jruby-container --jruby.home=/<jruby-install-location>

You can also change the deployment specific options to the JRuby application through the following command syntax:

asadmin deploy --property <name>=<value>[:<name>=<value>]

For example, the following command uses a JRuby instance to deploy your application which is different from the one configured with the Enterprise Server:

asadmin deploy --property jruby.home=/<latest-jruby-install> <application>

For a detailed description of these options, see configure-jruby-container(1).

The JRuby container runtime pool options are discussed in the next section.

Configuring JRuby Runtime Pool

The Sun GlassFish Enterprise Server v3 provides a JRuby runtime pool to allow servicing of multiple concurrent requests. However Rails is not currently thread-safe, and while JRuby is able to take advantage of Java's native threading, Rails cannot benefit from it. Each JRuby runtime runs a single instance of Rails, and requests are handed off to whichever instance happens to be available at the time of the request.

The JRuby properties in the above configuration are explained as follows:

The dynamic runtime pool maintains itself with the minimum number of runtimes possible, to allow consistent and fast runtime access for the requesting application. The pool may take a initial runtime value, but that value is not used after pool creation.

The JRuby runtime pool values can be set either at container level or at deploy time. To set the runtime pool values at container level, use the following asadmin command:

asadmin configure-jruby-container --jruby-runtime=2 --jruby-runtime-min=1 --jruby-runtime-max=3

Note that each of the above properties can be set separately at a time. To set the runtime pool values at deploy time use the following asadmin command:

asadmin deploy --property jruby-runtime=2:jruby-runtime-min=1:jruby-runtime-max=3

Each of the above properties also can be set at a time or at the same time. If both settings are used, deploy time settings take precedence over container runtime settings.

Configuring JRuby Container Through Administration Console

The JRuby container values can be set from Enterprise Server Administration Console. For details on Administration Console, see Administration Console in Sun GlassFish Enterprise Server v3 Administration Guide.

You can set the following container properties from the Administration Console:

Use the following steps to access JRuby Container from Administration Console.

ProcedureTo Configure JRuby Container from Administration Console

  1. Access the Enterprise Server Administration Console from web browser. For example:


    http://localhost:4848
  2. Login to the Administration Consoleif configured for secure login.

  3. Select Common Tasks->Configuration->JRuby Container on the left-hand tree panel.

  4. Change JRuby Container values from the details panel.

Creating a Simple Rails Application

After completing your installations, you are ready to start coding. This section shows you how to create a simple application that displays the following message:


Welcome to JRuby on Rails on the Sun GlassFish Enterprise Server!

ProcedureTo Create the hello Application

  1. Select a directory to create a sample application. For example:

    /apps/jruby-apps

  2. Create a Rails application called hello in that directory:

    cd /apps/jruby-apps

    jruby -S rails hello

    This command creates the hello directory, which contains a set of automatically-generated files and directories.

    The directories containing the files that you'll use the most are:

    • app: Contains your application code.

    • config: Contains configuration files, such as database.yml, which you use to configure a database.

    • public: Contains files and resources that need to be accessed directly rather than accessed through the Rails call stack. These include images and straight HTML files.

ProcedureTo Create the Controller and the View

The following task describes how to create a controller and a default view for your application. The controller handles requests, dispatches them to other parts of the application as necessary, and determines which view to render. The view is the file that generates the output to the browser. In Rails, views are typically written with ErB, a templating mechanism.

  1. Change to the directory where you created the hello application in the previous task. For example:

    /apps/jruby-apps/hello

  2. Create a controller and default view for your application:

    jruby script/generate controller home index

    You should see a controller file called home_controller.rb in the hello/app/controllers directory and a view file called index.html.erb in the hello/app/views directory.

ProcedureTo Pass Data From the Controller to the View

Exchanging data between the controller and the views is a common task in web application development. This section describes how to set an instance variable in the controller and access its value from the view.

  1. Go to the controller that you created in the previous task.

  2. Open the hello/app/controllers/home_controller.rb file in a text editor.

  3. Add an instance variable called @hello_message to the action called index, so that the controller looks like this:

    class HomeController < ApplicationController
    def index
    @hello_message = "Welcome to JRuby on Rails on the Sun GlassFish Enterprise Server"
    end
    end

    In Rails, the actions are supposed to map to views. So, when you access the index.html.erb file, the index action executes. In this case, the index action makes the @hello_message variable available to index.html.erb.

  4. Save the file.

  5. Open the hello/app/views/home/index.html.erb file in a text editor.

  6. At the end of the file, add the following output block:

    <%= @hello_message %>

    This JRuby code, embedded into the view, inserts the value of @hello_message into the page. When you run the application, you can see “Welcome to JRuby on Rails on the GlassFish Enterprise Server” in your browser.

  7. Save the file.

ProcedureTo Use Rails Without a Database

Although Rails is intended for creating database-backed web applications, this example is simple enough that it doesn't require one. In this case, you must edit the enviroment.rb configuration file to indicate that your application does not use a database.

  1. Open hello/config/environment.rb file in a text editor.

  2. Look for the following pattern in the file:

    #config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
  3. Remove the pound (#) character in the beginning of the line. The line should now read as follows:

    config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
  4. Exit and save the file.

Deploying and Running a Rails Application

As described in JRuby on Rails, the Sun GlassFish Enterprise Server v3, and the GlassFish v3 Gem, you have two ways to deploy your Rails application on the Enterprise Server:

For more details on running the Rails application using GlassFish v3 Gem, see To Run a Rails Application on GlassFish v3 Gem. This section shows you how to deploy the hello application that you created in the previous section, as a directory with the asdmin CLI and how to access the application from your web browser. You can also use these same instructions to deploy a legacy Rails application.

ProcedureTo Deploy the Rails Application as a Directory

You can use directory-based deployment to deploy any Rails application to the Enterprise Server. To deploy the hello application to the Enterprise Server as a directory, do the following:

  1. Start the Enterprise Server with the following command:

    asadmin start-domain

  2. Change to the directory where you created the sample application. For example:

    /apps/jruby-apps/hello

  3. Deploy the hello application with asadmin command:

    asadmin deploy hello

    • If you want to use a JRuby instance different from the update installation or the instance you configured with configure-jruby-container command, you can use the following deploy time option:

      asadmin deploy --property jruby.home=/jruby-install-location

  4. Run the hello application using the following URL in your browser:


    http://localhost:8080/hello/

Accessing a Database From a Rails Application

One of the main functions of Rails is to make a quick-and-easy task of creating an application that accesses a database. This section shows you the steps to create a simple application that accesses a book database using MySQLTM. You should have already installed JRuby, Rails, and the required Gems.

ProcedureTo Set Up the MySQL Database Server

  1. Download and install MySQL database server:

    MySQL 5.0 Community Server.

  2. Configure the server according to the MySQL documentation, including entering a root password.

  3. Start the server.

ProcedureTo Create a Database-Backed Rails Application

  1. Create or select a directory for creating a database-backed Rails application.

  2. Change to that directory.

  3. Create and configure a application template to use the MySQL database:

    jruby -S rails books -d mysql
  4. Change to the books directory that you just created.

  5. Replace mysql with jdbcmysql.

  6. Open the config/database.yml file in a text editor.

  7. When prompted, enter your MySQL root password under the development heading in the database.yml file.

  8. Change back to the books directory if you are not already there.

  9. Create the database by running the following command:

    jruby -S rake db:create

    After the database creation is complete, you should see output similar to the following:


    ** Execute db:create

    The rake command invokes the Rake tool. The Rake tool builds applications by running Rake files, which are written in Ruby and provide instructions for building applications.

  10. Create the scaffold and the Book model for the application:


    jruby script/generate scaffold book title:string 
    author:string isbn:string description:text

    When you run the script/generate command, you specify the name of the model, the names of the columns, and the types for the data contained in the columns.

    A scaffold is the set of code that Rails generates to handle database operations for a model object, which is Book in this case. The scaffold consists of a controller and some views that allow users to perform the basic operations on a database, such as viewing the data, adding new records, and editing records. Rails also creates the model object when generating the scaffold.

  11. Create the database tables:

    jruby -S rake db:migrate

    When Rails is finished creating the tables, you should see output similar to the following:


    CreateBooks: migrated (0.1322ms) =========

    If you need to reset the database later, you can run the following command:

    jruby —S rake db:reset

Accessing Java Libraries From a Rails Application

The primary advantage of developing with JRuby is that you have access to Java libraries from a Rails application. For example, say you might want to create an image database and a web application that allows processing of the images. You can use Rails to set up the database-backed web application and use the powerful Java 2DTM API for processing the images on the server-side.

This section shows you how to get started using Java libraries in a Rails application while stepping you through building a simple Rails application that does basic image processing with the Java 2D API.

This application demonstrates the following concepts involved in using Java libraries in a Rails application:

For simplicity's sake, this application does not use a database. You will need a JPEG file to run this application.

ProcedureTo Create the Rails Application That Accesses Java Libraries

  1. Change to the directory you want to create an application.

    /apps/jruby-apps/

  2. Create an application by running this command:

    jruby -S rails imageprocess
  3. Open the imageprocess/config/environment.rb file in a text editor.

  4. Follow steps 2 and 3 from the instructions in, To Use Rails Without a Database.

  5. Change to the imageprocess directory you just created.

  6. Create a controller and default view for the application by running this command:

    jruby script/generate controller home index
  7. Change to the imageprocess/app/views/home directory.

  8. Create a second view by copying the default view to seeimage.html.erb:

    cp index.html.erb seeimage.html.erb

ProcedureTo Create the Views That Display the Images Generated by Java2D Code

With this task, you will perform the following actions:

  1. Find a JPEG image that you can use with this application.

  2. Add the image to imageprocess/public/image file.

  3. Change to imageprocess/app/views/home directory.

  4. Open the index.html.erb file in a text editor.

  5. Replace the contents of this file with the following HTML markup:

    <html>
    	<body>
    		<img src="../../images/kids.jpg"/><p>
    		<%= link_to "Perform a ColorConvertOp on this image", :action => "seeimage" %>
    	</body>
    </html>

    This page loads an image from imageprocess/public/images and provides a link that references the seeimage action. The seeimage action maps to the seeimage view, which shows the processed image.

  6. Replace kids.jpg from line 3 of index.html.erb with the name of your image that you saved from Step 3 of this procedure.

  7. Save the index.html.erb file.

  8. Open the seeimage.html.erb file in a text editor.

  9. Replace the contents of this file with the following HTML markup:

    <html>
    	<body>
    		<img src="/home/processimage"/><p>
    		<%= link_to "Back", :action => "index" %>
    	</body>
    </html>

    The img tag on this page accesses the processimage action in HomeController. The processimage action is where you will put the Java2D code to process the image that you loaded into index.html.erb.

ProcedureTo Add Java2D Code to a Rails Controller

With this task, you will add the code to process your JPEG image.

  1. Add the following line to HomeController, right after the class declaration:

    include Java

    This line is necessary for you to access any Java libraries from your controller.

  2. Create a constant for the BufferedImage class so that you can refer to it by the shorter name:

    BI = java.awt.image.BufferedImage
  3. Add an empty action, called seeimage, at the end of the controller:

    def seeimage
    end

    This action is mapped to the seeimage.html.erb view.

  4. Give controller access to your image file using java.io.File, making sure to use the name of your image in the path to the image file. Place the following line inside the seeimage action:

    filename = "#{RAILS_ROOT}/public/images/kids.jpg"
    imagefile = java.io.File.new(filename)

    Notice that you don't need to declare the types of the variables, filename or imagefile. JRuby can tell that filename is a String and imagefile is a java.io.File instance because that's what you assigned them to be.

  5. Read the file into a BufferedImage object and create a Graphics2D object from it so that you can perform the image processing on it. Add these lines directly after the previous two lines:

    bi = javax.imageio.ImageIO.read(imagefile)
    w = bi.getWidth()
    h = bi.getHeight()
    bi2 = BI.new(w, h, BI::TYPE_INT_RGB)
    big = bi2.getGraphics()
    big.drawImage(bi, 0, 0, nil)
    bi = bi2
    biFiltered = bi

    Refer to The Java Tutorial for more information on the Java 2D API.

    The important points are :

    • You can call Java methods in pretty much the same way in JRuby as you do in Java code.

    • You don't have to initialize any variables.

    • You can just create a variable and assign anything to it. You don't need to give it a type.

  6. Add the following code to convert the image to gray scale:

    colorSpace = java.awt.color.ColorSpace.getInstance(
    java.awt.color.ColorSpace::CS_GRAY)
    op = java.awt.image.ColorConvertOp.new(colorSpace, nil)
    dest = op.filter(biFiltered, nil)
    big.drawImage(dest, 0, 0, nil);
  7. Stream the file to the browser:

    os = java.io.ByteArrayOutputStream.new
    javax.imageio.ImageIO.write(biFiltered, "jpeg", os)
    string = String.from_java_bytes(os.toByteArray)
    send_data string, :type => "image/jpeg", :disposition => "inline", 
    	:filename => "newkids.jpg"

    Sometimes you need to convert arrays from Ruby to Java code or from Java code to Ruby. In this case, you need to use the from_java_bytes routine to convert the bytes in the output stream to a Ruby string so that you can use it with send_data to stream the image to the browser. JRuby provides some other routines for converting types, such as to_java to convert from a Ruby Array to a Java String. See Conversion of Types.

ProcedureTo Run a Rails Application That Uses Java 2D Code

  1. Deploy the application on the GlassFish v3 Gem:

    asadmin deploy imageprocess

  2. Run the application by entering the following URL into your browser:

    http://localhost:3000/home/index

    You should now see an image and a link that says, “Perform a ColorConvertOp on this image.”

  3. Click the link.

    You should now see a grayscale version of the image from the previous page.

Monitor Rails Applications on Enterprise Server v3

The Enterprise Server v3 offers monitoring services for various objects.

Monitoring is the process of reviewing the statistics of a system to improve performance or solve problems. The monitoring service can track and display operational statistics, such as the number of requests per second, the average response time, and the throughput. For more information on monitoring, see Chapter 8, Administering the Monitoring Service, in Sun GlassFish Enterprise Server v3 Administration Guide.

Monitoring for JRuby Container

The JRuby Container installed on the Enterprise Server can be configured to be monitored. By default the monitoring services are disabled.

Monitoring can be configured for the container using the following asadmin CLI command:

configure-jruby-container --monitoring=true

The monitoring service can be enabled or disabled. Enable monitoring for GlassFish JRuby container with the following runtime command:

enable-monitoring --modules jruby-container=HIGH

The other possible values are OFF or LOW. Disable the monitoring for JRuby container with the following command:

disable-monitoring --modules jruby-container=OFF

Viewing JRuby Container Statistics

JRuby statistics are available from asadmin CLI as well as from Administration Console. To learn more about different types of JRuby statistics available from Enterprise Server, see JRuby Statistics in Sun GlassFish Enterprise Server v3 Administration Guide.

GlassFish v3 Gem

Another way to work with JRuby is to install the GlassFish v3 Gem on a JRuby standalone instance. The GlassFish v3 Gem is just a lightweight version of the Sun GlassFish Enterprise Server v3 that runs as part of JRuby instance.

When you install the GlassFish v3 Gem on JRuby, you have a Sun GlassFish instance embedded in the JRuby virtual machine. This gives you a more complete development environment because you have everything you need for JRuby on Rails applications running inside the JRuby virtual machine in addition to everything you need from the GlassFish Server to create web applications.

ProcedureTo Install the GlassFish v3 Gem

To install the GlassFish v3 Gem on your JRuby standalone instance, use the following procedure:

  1. Download and install JRuby according to the instructions in To Install JRuby as Standalone.

  2. Install Rails Gem according to the instructions in To Install Rails Gem on JRuby

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

    jruby -S gem install glassfish

  4. Start your server with the following command:

    jruby -S glassfish

ProcedureTo Run a Rails Application on GlassFish v3 Gem

You can also run your JRuby on Rails application on the embedded GlassFish v3 Gem. Create a simple Rails application as described in Creating a Simple Rails Application. Instead of deploying it to the Enterprise Server, use the GlassFish v3 Gem to run that application as described in the following task.

  1. Change to the directory where a sample application has been created. For example:

    cd /jruby-apps

  2. Deploy the previously created hello application:

    jruby -S glassfish helloV3

  3. Run the application using the following URL in your web browser:


    http://localhost:3000/home/index

    You should now see the following message in your browser window:

    Welcome to JRuby on Rails on the Sun GlassFish Enterprise Server!

    Note that the GlassFish v3 Gem runs on port 3000 and not the default port 8080.

ProcedureTo Deploy and Run the Database-Backed Web Application

Creating database-backed web applications was described in To Create a Database-Backed Rails Application. The following task describes running the created books application on the GlassFish v3 Gem. You can alternatively deploy it to your regular Enterprise Server using directory-based deployment, as described in To Deploy the Rails Application as a Directory.

  1. Change to /books directory.

  2. Deploy the application to the GlassFish v3 Gem by running the following command:

    jruby -S glassfish books
  3. Run the application in your web browser using the following URL:

    http://localhost:3000/books

    The opening page says “Listing books” and has an empty table, meaning that there are no book records in the database yet. To add book records to the table, do the next step.

  4. Add records to the table by clicking the New book link on the index.html page.

  5. Enter the data for book on the new.html page and click Create.

Using GlassFish v3 Gem CLI

The GlassFish v3 Gem offers several commands to configure the GlassFish server. You can change the configuration options either by using GlassFish command line or by modifying the glassfish.yml file. You view these options by using the following command:

glassfish -h

The options include runtimes, runtimes-min, runtimes-max, and also a configuration option to create a configuration file for GlassFish Server.

You can create a glassfish.yml file which is a default GlassFish configuration file generated by the following command:

jruby -S gfrake config

Introduction to Warbler

In Deploying and Running a Rails Application, direct deployment of a rails application to Enterprise Server has been described. Warbler provides an easier way to deploy a rails application to a Java application server.

What Is Warbler ?

Warbler is a Gem that makes WAR file out of a Rails, Merb, or Rack-based application. Warbler provides a minimal, flexible, Ruby-like way to bundle application files for deployment to a Java application server.

Warbler provides a set of out-of-the box defaults to allow most Rails applications to assemble and work without external Gem dependencies.

Warbler bundles JRuby and the JRuby-Rack Servlet adapter for dispatching requests to the application inside the Java application server, and assembles all jar files in the WARBLER_HOME/lib/ directory into the application.

To learn more about Warbler, see Warbler.

Creating and Deploying a Simple Rails Application with Warbler

The procedure for creating a simple Rails application for Warbler, is similar to the procedure described in Creating a Simple Rails Application.

ProcedureTo Create a Rails Application

  1. Create a new directory for the Warbler application. For example:

    mkdir rails-warbler

  2. Change to rails-warbler directory and create a sample application called hello:

    jruby -S rails hello
  3. Edit the enviroment.rb file to indicate that your application does not use a database:

    Open rails-warbler/hello/config/environment.rb in a text editor.

  4. Remove the pound character (#) in front of line 21 to uncomment it so that it reads as follows and save:

    config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
  5. Exit and save the file.

  6. Use Warbler to create a war file in rails-warbler/hello application directory:

    jruby -S warble

    This creates a hello.war file in the directory.

ProcedureTo Deploy the WAR File

  1. Change to the rails-warbler/hello application directory.

  2. Deploy the application WAR file to the Enterprise Server by running the asadmin command:

    asadmin deploy hello.war
  3. Run the hello application by entering the following URL in your browser:


    http://<hostname>:<port>/hello

Further Information

For more information on Ruby-on-Rails, JRuby, JRuby on Enterprise Server and Warbler, see the following resources: