Mephisto on GlassFish V3

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

Comments:

This is fantastic! I'm definitely going to look at this further, as I want to set up several Rails apps on the same system, each with its own prefix. Having to set up multiple Mongrel clusters, and proxy configurations in Apache, is rapidly becoming annoying. This is much cleaner, and probably more stable to boot. Thanks.

Posted by Nathan Fiedler on May 23, 2007 at 09:54 AM PDT #

Arun, Thank you for the great tutorial. I have one issue - when I go to http://localhost:8080/mephisto/admin all of the styling is gone (i.e. it appears to not find the stylesheets) so Mephisto doesn't look anything like is is supposed to. Any ideas? Also, is there a preferred environment (java version, glassfish version, etc.)? I appreciate your help. - robert dempsey

Posted by Robert Dempsey on May 27, 2007 at 10:43 AM PDT #

I used J2SE 5 (should work with Java SE 6 as well), GlassFish V3 Technology Preview 1 on Windows Vista Ultimate. I'll debug the stylesheet problem you mentioned and report back.

Posted by Arun on May 29, 2007 at 02:32 AM PDT #

Thank you sir. I too am using Glassfish V3, along with Java SE6 on a Mac. Here is the output of java -version: java version "1.5.0_07" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-164) Java HotSpot(TM) Client VM (build 1.5.0_07-87, mixed mode, sharing). I was told by the JRuby team to use JVM 6 so I downloaded and installed Java 6 Rel1 from the Apple Developer network and installed it. I apologize for my lack of understanding of Java, so if my java -version is not reporting my use of Java6 please let me know. Thank you again for your help.

Posted by Robert Dempsey on May 29, 2007 at 03:39 AM PDT #

Robert, "java -version" will show the version of JVM in your system path. It seems like you installed Java SE 6 Rel1 but did not include it in your path and that's why this discrepancy. But I do not see that as issue. It should still work because I've been using a slightly updated version (J2SE 5_011) all along. Other than styling issue, do you see any other issue in deploying the Mephisto ?

Posted by Arun on May 29, 2007 at 03:44 AM PDT #

Arun, Aside from the style issue, the site is working fine, though it seems a bit slow. I tried to run the asadmin command to undeploy mephisto and then deploy the .war file I created (adding it to the autodeploy folder I manually created), however, even though I got a "success" message, the app didn't seem to undeploy and starts up every time I fire up glassfish. When I run jruby script/server the site runs very quickly, hence my attempted test with the .war file. This is my first attempt with Glassfish, and I thank you for your help.

Posted by Robert Dempsey on May 29, 2007 at 03:50 AM PDT #

[Trackback] Using the instructions provided by Arun in his blog entry I was able to get the Typo blogging engine running in Glassfish v3 Preview. Initially I had tried to use JRuby 1.0.0RC2, but every time I tried to install the Rails gems, it would run out of mem...

Posted by Nathan's Lame Blog on June 02, 2007 at 05:57 PM PDT #

[Trackback] ActiveRecord-JDBC 0.5 is now available. As mentioned earlier, one of the main features in this release is simplified database configuration for JRuby-on-Rails applications. From the release notes: It is no longer necessary to specify :driver and :url c...

Posted by Arun Gupta's Blog on August 27, 2007 at 03:35 AM PDT #

[Trackback] In an Earlier Post, I described how Mephisto (a popular web publishing system based on Ruby on Rails) can be deployed on GlassFish V3. Both JRuby and GlassFish has matured since then and this post will provide the updated instructions...

Posted by Arun Gupta's Blog on November 14, 2007 at 10:19 PM PST #

[Trackback] Pramod published an updated JRuby Gem for GlassFish v3. Download the gem here. Here are the updates from last time: The Gem is now smaller - 2.4 MB instead of 2.9 MB (approx 20% smaller). The Gem is now using...

Posted by Arun Gupta's Blog on January 04, 2008 at 10:27 PM PST #

[Trackback] 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...

Posted by Arun Gupta's Blog on August 27, 2008 at 10:50 PM PDT #

[Trackback] 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...

Posted by Arun Gupta's Blog on August 27, 2008 at 10:57 PM PDT #

[Trackback] Last day of Rails Conf Europe 2008 (Day 1 & Day 2), and it's finally over! David Black's opening session talked about Ruby and Rails Symposium: Versions, Implementations, and the Future. Here is a brief summary of MRI Ruby...

Posted by Arun Gupta's Blog on September 05, 2008 at 03:19 PM PDT #

[Trackback] GlassFish v3 Prelude is now available. It allows Rails applications to be deployed natively using JRuby and without the need of any WAR packaging or Servlet container. An integrated NetBeans tooling provides a comprehensive development and deploy...

Posted by Arun Gupta's Blog on November 06, 2008 at 09:52 PM PST #

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

Posted by LAPTOP BATTERY on November 27, 2008 at 08:49 AM PST #

I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

Sarah

http://www.craigslistdecoded.info

Posted by Sarah on February 19, 2009 at 10:12 PM PST #

Post a Comment:
Comments are closed for this entry.
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