Database-enabled RoR WAR on GlassFish

UPDATE: Simplified steps for GlassFish V2 are available here and for V3 here.

Follow up from here.

In this post I'll show how a Ruby-on-Rails (RoR) application, talking to MySQL database, can be deployed as a WAR file on GlassFish V2. Here are the steps I followed:

  1. Create a HelloWorld RoR app talking to MySQL database as described here.
  2. Expand NetBeans project, expand 'Configuration' and open 'database.yml'. Change production database entry from:

    production:
      adapter: mysql
      database: HelloWorld_production
      username: root
      password:
      host: localhost

    to

    production:
      adapter: jdbc
      driver: com.mysql.jdbc.Driver
      url: jdbc:mysql://localhost:3306/helloworld_development
      username: root
      password:


    Notice, even though this is production setting we are using a "development" database.
  3. In 'Configuration', 'environment.rb', add

    require 'jdbc_adapter'

    right before

    Rails::Initializer.run do |config|

    On some platforms, this syntax has caused problems. In that case, it may alternatively be specified (step 9) as:
    if RUBY_PLATFORM =~ /java/
           require 'rubygems'
           RAILS_CONNECTION_ADAPTERS = %w(jdbc)
    end
  4. Recreate the WAR file by invoking the command 'rake war:standalone:create' from your application directory.
  5. Drop this WAR file in "domains/domain1/autodeploy" directory of your GlassFish instance and you are done!

With this, you've deployed a Ruby-on-Rails application accessing MySQL database as a WAR file on GlassFish V2.

Technorati: glassfish rubyonrails ror netbeans jruby ruby

Comments:

[Trackback] Craig announced jMaki on Rails. Here I provide detailed steps to read data from a MySQL database and display it in a jMaki-wrapped Yahoo DataTable widget. Download NetBeans 6.0 M9 (Full version) and configured to install only "Base IDE", &quo...

Posted by Arun Gupta's Blog on May 17, 2007 at 06:56 AM PDT #

[Trackback] Tim Bray, Web Guy from Sun Microsystems gave the keynote session at Rails Conf 2007 yesterday (May 19). With 1600 attendees, it was quite a different experience from JavaOne last week which had approx 16,000 people. The session was to...

Posted by Arun Gupta's Blog on May 20, 2007 at 02:17 AM PDT #

[Trackback] Based upon a user request, this is a follow up entry to show how jMaki on Rails For Dummies work on NetBeans 6 Milestone 10. Some of the steps are simplified and more details are provided. The updates from the...

Posted by Arun Gupta's Blog on July 23, 2007 at 04:21 AM PDT #

[Trackback] Get ready for an interactive afternoon of coding and discussion on JRuby and GlassFish on Aug 8th in San Francisco, CA. In this free event, JRuby on Rails: Power plus simplicity, learn how to code and deploy a JRuby...

Posted by Arun Gupta's Blog on August 07, 2007 at 02:59 AM PDT #

[Trackback] Earlier in a three-part series (part1, part2, part3) I showed how a JRuby application can be deployed on GlassFish. This screencast consolidates all the entries together and shows how such an application can be developed and deployed using NetBeans...

Posted by Arun Gupta's Blog on August 08, 2007 at 02:46 AM PDT #

[Trackback] As reported earlier, Sun Microsystems and Joyent co-sponsored a free JRuby on Rails: Power plus simplicity Hackday. This event happened yesterday at Axis Cafe, San Francisco and the room was completely sold out. I reached the venue around 2:30pm and...

Posted by Arun Gupta's Blog on August 09, 2007 at 04:20 AM 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 #

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