Thursday Sep 17, 2009

TOTD #104: Popular Ruby-on-Rails applications on GlassFish v3 – Redmine, Typo, Substruct

GlassFish v3 is opening up new frontiers by allowing to easily deploy Rails, Grails and Django applications, in addition to Java EE, without any additional packaging. You can even write a custom container to support new types of applications. Numerous entries on this blog have talked about how to deploy Rails applications on GlassFish v3. This Tip Of The Day (TOTD) will recap them and, once again, demonstrate how to easily get started with deploying some popular open source Rails applications on GlassFish v3.

Lets prepare a GlassFish v3 build for deploying Rails applications. This blog is going to use 9/16 nightly but you should pick the latest nightly or promoted.

  1. Unzip the downloaded bundle as:
    ~/tools/glassfish/v3/9-16 >unzip ~/Downloads/glassfish-v3-b64-09_16_2009.zip
  2. Configure JRuby/Rails in GlassFish v3 - JRuby/rails can be configured three different ways - use a previously installed JRuby/Rails directory, install JRuby/Rails module using the graphical Update Center or the "pkg" binary. This Update Center module comes packaged with JRuby 1.3.1, Rails 2.3.2 and some other useful gems. Pick the option you are most comfortable with and use it for your GlassFish installation.
    1. Configure previously installed JRuby/Rails directory as:
      ~/tools/glassfish/v3/9-16/glassfishv3/bin/asadmin create-jvm-options -Djruby.home=/Users/arungupta/tools/jruby
      Authentication failed with password from login store: /Users/arungupta/.asadminpass
      
      Enter admin password >
      created 1 option(s)
      Command create-jvm-options executed successfully.

      That's it!
    2. Install JRuby/Rails module using graphical Update Tool
      1. The graphical Update Tool tool can be invoked as:
        ~/tools/glassfish/v3/9-16/glassfishv3 >./bin/updatetool
        
        The software needed for this command (updatetool) is not installed.
        
        If you choose to install Update Tool, your system will be automatically
        configured to periodically check for software updates. If you would like
        to configure the tool to not check for updates, you can override the
        default behavior via the tool's Preferences facility.
        
        When this tool interacts with package repositories, some system information
        such as your system's IP address and operating system type and version
        is sent to the repository server. For more information please see:
        
        http://wiki.updatecenter.java.net/Wiki.jsp?page=UsageMetricsUC2
        
        Once installation is complete you may re-run this command.
        
        Would you like to install Update Tool now (y/n): y
        
        Proxy: Using system proxy settings.
        Install image: /Users/arungupta/tools/glassfish/v3/9-16/glassfishv3
        Installing pkg packages.
        Installing updatetool packages.
        Registering notifier: Already registered.
        Initialization complete.
        
        Software successfully installed. You may now re-run this command (updatetool).
      2. The first invocation of the command installs the Update Tool and the second invocation shows the following screen after "JRuby on GlassFish" module is selected:


        Click on green button in the top left to install the module and it picks up the dependencies as well as shown below:


        Click on "Install" to start the installation and click on "Accept" to accept the license.
      3. Close the Update Tool window once the installation is completed. The module creates "glassfish/jruby" directory.
    3. Install JRuby/Rails module using "pkg" binary
      1. Install the JRuby/Rails bits using the "pkg" binary. Invoke the command as:
        ~/tools/glassfish/v3/9-16/glassfishv3 >./bin/pkg

        The software needed for this command (pkg) is not installed. When this tool interacts with package repositories, some system information such as your system's IP address and operating system type and version is sent to the repository server. For more information please see: http://wiki.updatecenter.java.net/Wiki.jsp?page=UsageMetricsUC2 Once installation is complete you may re-run this command. Would you like to install this software now (y/n): y Proxy: Using system proxy settings. Install image: /Users/arungupta/tools/glassfish/v3/9-16/glassfishv3 Installing pkg packages. Initialization complete. Software successfully installed. You may now re-run this command (pkg).
      2. The command "pkg list -a" shows all the modules available for installation and the output looks like:

        ~/tools/glassfish/v3/9-16/glassfishv3 >./bin/pkg list -a
        NAME (PUBLISHER)                              VERSION         STATE      UFIX
        ant (contrib.glassfish.org)                   1.7.1-0.6       known      ----
        felix                                         2.0.0-0         installed  ----
        glassfish-appclient                           3.0-65          installed  ----
        glassfish-cmp                                 3.0-65          installed  ----
        
        . . .
        
        jersey-docs-and-examples                      1.1.2-1.0       known      ----
        jmaki (contrib.glassfish.org)                 1.8.1-2.0       known      ----
        jruby                                         1.3.1-1.1       known      ----
        jruby (contrib.glassfish.org)                 1.2.0-1.1       known      u---
        jruby-gems (contrib.glassfish.org)            2.3.2-1.1       known      ----
        jython-container (contrib.glassfish.org)      0.5.3-1.0       known      ----
        jython-runtime (contrib.glassfish.org)        2.5.0-1.0       known      ----
        metro                                         2.0-19          installed  ----
        
        . . .
        
        updatetool                                    2.3.0-36.2403   known      ----
        updatetool (contrib.glassfish.org)            2.2.2-30.2311   known      u---
        wxpython2.8-minimal                           2.8.10.1-36.2403 known      ----
        wxpython2.8-minimal (contrib.glassfish.org)   2.8.8-30.2311   known      u---
      3. Start the installation of "jruby" module as:

        ~/tools/glassfish/v3/9-17/glassfishv3 >./bin/pkg install jruby
        DOWNLOAD                                  PKGS       FILES    XFER (MB)
        Completed                                  2/2 14810/14810    37.0/37.0
        
        PHASE                                        ACTIONS
        Install Phase                            17273/17273
  3. Redmine on GlassFish - Redmine is an open source project management web application. The simplified steps to deploy Redmine on GlassFish v3 are given below (also on GlassFish Gem and on GlassFish v3 TP2):
    1. Download and unzip Redmine 0.8.5 (latest stable release).
    2. Change the database adapter from "mysql" to "jdbcmysql" as:

      sed s/'adapter: mysql'/'adapter: jdbcmysql'/ <config/database.yml.new >config/database.yml
    3. Create the database manually as "sudo mysqladmin create redmine_development". "db:create" fails because of JRUBY-3502.
    4. Migrate the database as "db:migrate".
    5. Deploy the application as:
      ~/samples/jruby/redmine >~/tools/glassfish/v3/9-16/glassfishv3/bin/asadmin deploy redmine-0.8.5
       Authentication failed with password from login store: /Users/arungupta/.asadminpass
      
      Enter admin password>
      Command deploy executed successfully.
    6. Here are some snapshots from the deployed application:





  4. Typo on GlassFish - Typo is the oldest Ruby on Rails blogware. The simplified steps to deploy Typo on GlassFish v3 are given below (also on GlassFish Prelude):
    1. Download and unzip Typo 5.3 (latest stable release).
    2. Change the database adapter from "mysql" to "jdbcmysql" as:

      sed s/'adapter: mysql'/'adapter: jdbcmysql'/ <config/database.yml.example >config/database.yml
    3. Create the database manually as "sudo mysqladmin create typo_dev". "db:create" fails because of JRUBY-3502.
    4. Typo runs using Rails 2.2.2 so lets install Rails 2.2.2 so lets install Rails 2.2.2 as:
      ~/samples/jruby/typo/typo-5.3 >~/tools/glassfish/v3/9-16/glassfishv3/glassfish/jruby/bin/jruby -S gem install rails -v 2.2.2
      JRuby limited openssl loaded. gem install jruby-openssl for full support.
      http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
      Successfully installed activesupport-2.2.2
      Successfully installed activerecord-2.2.2
      Successfully installed actionpack-2.2.2
      Successfully installed actionmailer-2.2.2
      Successfully installed activeresource-2.2.2
      Successfully installed rails-2.2.2
      6 gems installed
      Installing ri documentation for activesupport-2.2.2...
      Installing ri documentation for activerecord-2.2.2...
      Installing ri documentation for actionpack-2.2.2...
      Installing ri documentation for actionmailer-2.2.2...
      Installing ri documentation for activeresource-2.2.2...
      Installing ri documentation for rails-2.2.2...
      Installing RDoc documentation for activesupport-2.2.2...
      Installing RDoc documentation for activerecord-2.2.2...
      Installing RDoc documentation for actionpack-2.2.2...
      Installing RDoc documentation for actionmailer-2.2.2...
      Installing RDoc documentation for activeresource-2.2.2...
      Installing RDoc documentation for rails-2.2.2...
    5. Migrate the database as "db:migrate".
    6. Deploy the application as:
      ~/samples/jruby/typo >~/tools/glassfish/v3/9-16/glassfishv3/bin/asadmin deploy typo-5.3
      Authentication failed with password from login store: /Users/arungupta/.asadminpass
      
      Enter admin password>
      Command deploy executed successfully.
    7. Here are are some snapshots from the deployed application:





  5. Substruct on GlassFish - Substruct is an open source E-Commerce project in Ruby-on-Rails. The simplified steps to deploy Substruct on GlassFish v3 are given below (also on GlassFish v3 Gem):
    1. Download and unzip substruct 1.0 a6 (latest stable release).
    2. Install the required gems as:
      ~/samples/jruby/substruct >~/tools/glassfish/v3/9-16/glassfishv3/glassfish/jruby/bin/jruby -S gem install RedCloth fastercsv mime-types mini_magick ezcrypto jruby-openssl --no-ri --no-rdoc
    3. Change the database adapter from "mysql" to "jdbcmysql" as:

      ~/samples/jruby/substruct/substruct_rel_1-0-a6>sed s/'adapter: mysql'/'adapter: jdbcmysql'/ <config/database.yml
      >config/database.yml.new
      ~/samples/jruby/substruct/substruct_rel_1-0-a6>mv config/database.yml.new config/database.yml
    4. Create the database manually as "sudo mysqladmin create substruct_development". "db:create" fails because of JRUBY-3502.
    5. Initialize the database as:
      ~/samples/jruby/substruct/substruct_rel_1-0-a6 >~/tools/glassfish/v3/9-16/glassfishv3/glassfish/jruby/bin/jruby -S rake substruct:db:bootstrap
    6. Deploy the application as:
      ~/samples/jruby/substruct >~/tools/glassfish/v3/9-16/glassfishv3/bin/asadmin deploy substruct_rel_1-0-a6
      Authentication failed with password from login store: /Users/arungupta/.asadminpass
      Enter admin password>
      
      Command deploy executed successfully.
    7. Here is a snapshot of the deployed application:

So we deployed Redmine, Typo, and Substruct using JRuby/Rails on GlassFish without any additional packaging. There are several Rails applications deployed in production on GlassFish.

What Rails applications are you deploying on GlassFish ?

Technorati: glassfish v3 rubyonrails jruby redmine typo mephisto substruct

Wednesday Aug 27, 2008

Typo on GlassFish v3 - Ruby-on-Rails Blogging Engine



Typo is an open-source Blogging Engine written using Ruby-on-Rails framework. It provides a lean engine that makes blogging easy. It's main attribtues are ease of use, usability, beauty and excellent support of web standards.

I found out about this application from Sang "Passion" Shin's Lab 5543 (part of FREE 20-week course on Ruby-on-Rails started on Jul 15, 2008). But instead of using standard WEBrick/Mongrel deployment, I describe the steps to deploy this application using GlassFish v3 that supports native deployment of Rails applications. 
  1. Typo can be installed as Gem or from Sources. Installing as gem gives the following error:

    JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    Building native extensions.  This could take a while...
    /Users/arungupta/tools/rails20/jruby-1.1.3/lib/ruby/1.8/mkmf.rb:7: JRuby does not support native extensions. Check wiki.jruby.org for alternatives. (NotImplementedError)
            from /Users/arungupta/tools/rails20/jruby-1.1.3/lib/ruby/1.8/mkmf.rb:1:in `require'
            from extconf.rb:1
    ERROR:  Error installing typo:
            ERROR: Failed to build gem native extension.

    /Users/arungupta/tools/rails20/jruby-1.1.3/bin/jruby extconf.rb install typo


    Gem files will remain installed in /Users/arungupta/tools/rails20/jruby-1.1.3/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
    Results logged to /Users/arungupta/tools/rails20/jruby-1.1.3/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

    This is discussed here. In the meanwhile, download and unzip Typo 5.1.2 as:

    ~/samples/jruby >unzip ~/Downloads/typo-5.1.2.zip
    Archive:  /Users/arungupta/Downloads/typo-5.1.2.zip
       creating: typo-5.1.2/
       creating: typo-5.1.2/app/
       creating: typo-5.1.2/app/apis/
       . . .
      inflating: typo-5.1.2/vendor/uuidtools/lib/uuidtools.rb 
      inflating: typo-5.1.2/vendor/uuidtools/rakefile 
      inflating: typo-5.1.2/vendor/uuidtools/README
  2. Create the database:

    ~/samples/jruby >sudo mysqladmin create typo_dev

    Typo 5.1.x works with Rails 2.0.x only and so migrate as shown below:

    ~/samples/jruby/typo-5.1.2 >~/tools/rails20/jruby-1.1.3/bin/jruby -S rake db:migrate
    (in /Users/arungupta/samples/jruby/typo-5.1.2)
    == 1 InitialSchema: migrating =================================================
    -- create_table(:users)
       -> 0.0377s
    -- create_table(:articles)
       -> 0.0189s
    -- add_index(:articles, :permalink)
       -> 0.0094s
    -- create_table(:categories)
       -> 0.0069s

     . . .

    == 69 AddModulesToProfile: migrating ==========================================
    -- add_column(:profiles, :modules, :text)
       -> 0.0072s
    == 69 AddModulesToProfile: migrated (0.0454s) =================================

    == 70 AddUsersToNonAdmins: migrating ==========================================
    == 70 AddUsersToNonAdmins: migrated (0.0488s) =================================

  3. Typo 5.2 (scheduled in 3 days) will work with Rails 2.1.
  4. Download GlassFish (nightly, promoted or build-your-own) and install by unzipping. I tried the nightly of 8/24 as:

    ~/tools/glassfish/v3/8-24 >unzip ~/Downloads/glassfish-snapshot-v3-prelude-08_24_2008.zip
    Archive:  /Users/arungupta/Downloads/glassfish-snapshot-v3-prelude-08_24_2008.zip
       creating: glassfish/
       creating: glassfish/docs/
       creating: glassfish/docs/css/
       creating: glassfish/docs/graphics/
    . . .
      inflating: glassfish/lib/templates/login.conf 
      inflating: glassfish/lib/templates/profile.properties 
      inflating: glassfish/lib/templates/server.policy
  5. Start GlassFish as:

    ~/tools/glassfish/v3/8-24/glassfish >java -DJRUBY_HOME=/Users/arungupta/tools/rails20/jruby-1.1.3 -jar modules/glassfish-10.0-SNAPSHOT.jar
    Aug 26, 2008 5:56:10 PM com.sun.enterprise.glassfish.bootstrap.ASMain main
    INFO: Launching GlassFish on Apache Felix OSGi platform

    Welcome to Felix.
    =================

    Aug 26, 2008 5:56:11 PM HK2Main start
    INFO: contextRootDir = /Users/arungupta/tools/glassfish/v3/8-24/glassfish/modules
    Aug 26, 2008 5:56:11 PM OSGiFactoryImpl initialize

    . . .

    INFO: APIClassLoader = Class Loader for Bundle [GlassFish-Application-Common-Module [66] ]
    Aug 26, 2008 5:56:13 PM CommonClassLoaderManager Skipping creation of CommonClassLoader as there are no libraries available
    INFO: urls = []
    Aug 26, 2008 5:56:13 PM com.sun.enterprise.v3.server.AppServerStartup run
    INFO: Glassfish v3 started in 2176 ms
  6. And deploy Typo as:

    ~/samples/jruby >~/tools/glassfish/v3/8-24/glassfish/bin/asadmin deploy typo-5.1.2

    Command deploy executed successfully.
The application is available at "http://localhost:8080/typo-5.1.2" and some of the screenshots follow:

















Also check out Redmine, Substruct and Mephisto on GlassFish v3. There are some performance issues when running Typo on GlassFish and this is tracked at Issue #5662.

If your Rails application does not work on the gem, file bugs here with "jruby" as "subcomponent" (default version is "v3").

Technorati: rubyonrails glassfish v3 jruby ruby typo blogging
About

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.


Java EE 7 Samples

Stay Connected

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today