Skip to main content

Mephisto on GlassFish V3

Posted by arungupta on May 22, 2007 at 6:16 PM PDT

This blog shows how Mephisto, a web
publishing system based on Ruby on Rails,
can be deployed on
GlassFish V3 with minimal changes. These detailed steps are derived from the
original instructions. Here are the exact steps that I followed:

  1. Download Install

    GlassFish V3 Technology Preview 1
    (lets say GLASSFISH_HOME).
  2. Install and Configure JRuby
    1. Download and Install JRuby1.0
      RC2
      in 'GLASSFISH_HOME/lib' directory. Rename the installation directory
      to 'jruby' (lets say JRUBY_HOME).
    2. Include 'JRUBY_HOME/bin' in your environment PATH.
    3. Install Rails and ActiveRecord gems in JRuby installation by giving the
      command:



      gem install rails -y --no-rdoc

      gem install activerecord-jdbc -y --no-rdoc
    4. Download and Install
      MySQL/J
      Connector
      in a new directory. Copy the JAR file from the main installation directory to
      'JRUBY_HOME/lib' directory.
  3. Install and Configure Database
    1. Download and install
      MySQL Community
      Server 5.0
      (lets say MYSQL_HOME).
    2. Start MySQL database by giving the command 'mysqld-nt --user root --console'
      in MYSQL_HOME/bin directory on Windows or './bin/mysqld_safe'
      from MYSQL_HOME directory on Unix flavors.
    3. Create a database and grant privileges by giving the following commands:

       
      MYSQL_HOME/bin/mysql -u root

      mysql> create database mephisto character set utf8;

      Query OK, 1 row affected (0.00 sec)



      mysql> grant all on mephisto.* to arun@localhost identified by 'noway';

      Query OK, 0 rows affected (0.00 sec)



      mysql> flush privileges;

      Query OK, 0 rows affected (0.00 sec)



      mysql> quit;

      Bye
  4. Install and Configure Mephisto
    1. Download and unzip
      Mephisto 0.7.3.
      Rename the installation directory to 'mephisto' (lets say
      MEPHISTO_HOME) for convenience.
    2. Install Mephisto as described
      here. The two steps are
      summarized below for convenience:
      1. Copy 'MEPHISTO_HOME/config/database.example.yml'
        to 'MEPHISTO_HOME/config/database.yml'. Change database entries in the
        file from:



        development:

          adapter: mysql

          database: mephisto_development

          username: root

          password:

          host: localhost




        to



        development:

          adapter: jdbc

          driver: com.mysql.jdbc.Driver

          url: jdbc:mysql://localhost:3306/mephisto

          username: arun

          password: noway
      2. Edit 'MEPHISTO_HOME/config/environment.rb', add the following
        fragment before "Rails::Initializer.run" statement.



        if RUBY_PLATFORM =~ /java/

          require 'rubygems'

          RAILS_CONNECTION_ADAPTERS = %w(jdbc)

        end
      3. Run 'rake db:bootstrap' to bootstrap the
        development database. On windows, you may have to invoke this
        command as '
        JRUBY_HOME\bin\jruby.bat JRUBY_HOME\bin\rake 
        db:bootstrap
        '.
  5. Start GlassFish V3 by invoking the following command in
    	GLASSFISH_HOME
    :



    java -jar lib/glassfish-10.0-SNAPSHOT.jar
  6. Deploy the application from 'GLASSFISH_HOME/bin' as:



    asadmin deploy --path MEPHISTO_HOME
  7. Mephisto is now deployed at 'http://localhost:8080/mephisto'.

This shows how a Ruby application, with minimal change, can be deployed on
GlassFish V3. This was also shown in the
JavaOne 2007
Technical keynote
(start @ 8:29 and finish @ 10:50).

I encourage you to try other popular Rails applications on GlassFish and
leave your feedback here.

Technorati:
glassfish
mephisto
rubyonrails

ror jrubyonglassfish

Related Topics >>