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

Deploying and Running a Rails Application

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

This section shows you how to deploy the hello application you created in the previous section natively and with the GlassFish v3 Gem and how to run the application in your web browser. You can also use these same instructions to deploy a legacy Rails application.

ProcedureDeploying a Rails Application as a Directory

You can use directory-based deployment to deploy any Rails application natively to the Sun GlassFish Enterprise Server. To natively deploy the hello application to the Enterprise Server:

  1. Set JRUBY_HOME property value to the path to your JRuby installation as the last line in one of the following files, located in the config directory of Enterprise Server your installation:

    • For Windows systems: asenv.bat

    • For Unix systems: asenv.conf

  2. Save the file.

  3. Edit <AS_INSTALL>/domains/domain1/config/domain.xmland add this entry inside element:

    <java-config>
    ...
    <jvm-options>-Djruby.home=<JRUBY_HOME></jvm-options>
    ...
    </java-config>

    Note –

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


  4. Start the server.

  5. Go to <JRUBY_HOME>/samples.

  6. Deploy the hello application with asadmin command from your Enterprise Server installation:

    <AS_INSTALL>/bin/asadmin deploy hello
  7. Run the hello application using the following URL in your browser:

    http://localhost:8080/hello/home/index

ProcedureDeploying a Rails Application to the GlassFish v3 Gem

  1. Go to <JRUBY_HOME>/samples.

  2. Deploy the hello application:

    jruby -S glassfish_rails helloV3

    When the GlassFish instance is finished launching, you should see output similar to the following:

    INFO: Rails instance instantiation took : 37754ms
  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!

    Notice that the GlassFish v3 Gem runs on port 3000, not 8080.