Miles to go ...

Arun Gupta is a Technology Evangelist for Web Services and Web 2.0 Apps at Sun. He was the spec lead for APIs in the Java platform, committer in multiple Open Source projects, participated in standard bodies and contributed to Java EE and SE releases.
« Database-enabled... | Main | jMaki on Rails For... »

http://blogs.sun.com/arungupta/date/20070517 Thursday May 17, 2007

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

del.icio.us | furl | simpy | slashdot | technorati | digg
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 01:56 PM 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 09: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 11: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 09: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 09: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 11: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 10:35 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
« Database-enabled... | Main | jMaki on Rails For... »

Valid HTML! Valid CSS!

This is a personal weblog, I do not speak for my employer.

--> ajax ajaxworld conf eclipse fitness gem glassfish glassfishday hyderabad india indigo interoperability javaone javaone2008 jax-ws jmaki jpa jruby mac marathon metro microsoft mysql netbeans phobos photography presos railsconf ruby rubyonrails running runninglog runsfm screencast siliconvalleymarathon sun suntechdays swdp tango theserverside totd training traveltips v3 vista wcf web2.0 webservices webtier windows wsaddressing wsit
Locations of visitors to this page

calendar

« July 2008
SunMonTueWedThuFriSat
  
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
31
  
       
Today

Stats

Today's Page Hits: 8444


Total # blog entries: 629
Total # comments: 1787

www.flickr.com
This is a Flickr badge showing public photos from ArunGupta. Make your own badge here.
Add to Technorati Favorites

Last 50