Ruby-on-Rails Hello World on GlassFish

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

Ashish described how to create RoRaWAR (Ruby on Rails as Web ARchive). I decided to try these instructions on GlassFish V2 b46. Here are the steps I followed:

  1. Create a simple "Hello World" RoR application using NetBeans 6.0 M9 following this screencast. NetBeans IDE creates a standard Rails application for you which can be easily created using "rails hello_demo" command as well.
  2. Install the "goldspike" (nee rails-integration) plug-in by giving the following command:

    script/plugin install svn://rubyforge.org/var/svn/jruby-extras/trunk/rails-integration/plugins/goldspike

    On a Windows machine, this command can be invoked as:

    ruby script/plugin install svn://rubyforge.org/var/svn/jruby-extras/trunk/rails-integration/plugins/goldspike

    The correct installation of this plug-in can be confirmed by checking for the presence of "vendor/plugins/goldspike" directory in your application directory. This plug-in's purpose is to WAR'up a RoR application.
  3. After the plug-in is installed, right-select the NetBeans project, select "Run Rake Target", select "Refresh Target List". This will add a new category, "war", of rake targets. Select "war", "standalone", "create" to create a stand-alone WAR file. This is equivalent to invoking the command "rake war:standalone:create". This will archive the Rails framework libraries in the WAR file.
  4. Drop this WAR file in "domains/domain1/autodeploy" directory of your GlassFish instance and you are done!

This is really simple. I'll add database interaction in this app and report back.

Read more on Rails Integration with JavaEE servers.

Technorati: glassfish rubyonrails ror netbeans jruby ruby

Comments:

[Trackback] Follow up from here. In this post I show how a Rails app can talk to database and then deployed as WAR on GlassFish V2. Here are the steps I followed: Deploy a RoR application as WAR on GlassFish using...

Posted by Arun Gupta's Blog on May 16, 2007 at 08:22 AM PDT #

Nice posting! I was trying to add the goldspike plugin on Mac, and found that I had to call jruby explicitly to get it to work. My command looks like: platinum:~/devel/netbeans_projects/Patterns > jruby script/plugin install svn://rubyforge.org/var/svn/jruby-extras/trunk/rails-integration/pl ugins/goldspike

Posted by John Stanford on June 10, 2007 at 02:41 AM PDT #

John, thanks for the tip. This is how the command is invoked on Windows machine as well and mentioned in the blog entry.

Posted by Arun on June 10, 2007 at 10:04 AM PDT #

gr8 post... thanks... I tried to follow the steps but ruby script/plugin install svn://rubyforge.org/var/svn/jruby-extras/trunk/rails-integration/plugins/goldspike seems to be not working... it does not error out .... just nothing happens... any reason behind ?

Posted by Amit on June 12, 2007 at 10:01 PM PDT #

Amit, after executing the command, do you see "vendor/plugins/goldspike" in your application directory ?

Posted by Arun on June 13, 2007 at 01:53 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 #

Hello. Thank you for your work. I am trying to follow the posted instructions for installing the Goldspike and unfortunately it does not work. I have NetBeans 6 M10 installed on Windows XP and when I execute the following command:
C:\\Program Files\\NetBeans 6.0M10\\ruby1\\jruby-1.0\\bin>jruby script/plugin install svn://rubyforge.org/var/svn/jruby-extras/trunk/rails-integration/plugins/goldsp
ike
I get the following error:
Error opening script file: script\\plugin (The system cannot find the path specif
ied)

SVN client is installed.

Would you know what a solution to this issue might be? Thank you!

Eugene

Posted by Eugene on August 22, 2007 at 11:49 PM PDT #

Just found a solution to my problem. Simple really.

This was done with
Product Version: NetBeans IDE 6.0 M10 (build 200706281431)
Java: 1.6.0_01; Java HotSpot(TM) Client VM 1.6.0_01-b06
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
Userdir: C:\\Documents and Settings\\xyz\\.netbeans\\6.0m10

Create a Rails application in NetBeans
Right click on the created Rails app and select "Rails plugins"
Click on "Repositories" tab
Click on "Add URL"
In the pop-up window enter "http://jruby-extras.rubyforge.org/svn/trunk/rails-integration/plugins" and click OK
Wait for the repository to load
Select the newly loaded repository
Click on the "New Plugins" tab
Wait for the list of plugins to load
Select "goldspike: http://jruby-extras.rubyforge.org/svn/trunk/rails-integration/plugins/goldspike/" plugin and click install
Click OK in the pop-up window
Wait for installation to finish
Close two pop-up windows
now use Arun Gupta's instructions (http://blogs.sun.com/arungupta/entry/ruby_on_rails_hello_world)
# The correct installation of this plug-in can be confirmed by checking for the presence of "vendor/plugins/goldspike" directory in your application directory. This plug-in's purpose is to WAR'up a RoR application.
# After the plug-in is installed, right-select the NetBeans project, select "Run Rake Target", select "Refresh Target List". This will add a new category, "war", of rake targets.

Note: if you get an error regarding being unable to delete "rake-t", then using windows explorer navigate to "path to your RoR project\\nbproject\\private" and renate rake-t file to rake-t.old. Try "Refreshing Target List" again.

Select "war", "standalone", "create" to create a stand-alone WAR file. This is equivalent to invoking the command "rake war:standalone:create". This will archive the Rails framework libraries in the WAR file.

Note: war file will be created in "path to your RoR project" directory

# Drop this WAR file in "domains/domain1/autodeploy" directory of your GlassFish instance and you are done!

Note: app can be accessed via:

http://myglassfishserver.myserver.com:8080/NameOfMyRailsApplication/controller/method

Posted by Eugene on August 23, 2007 at 12:32 AM PDT #

Eugene, This is exactly what is shown at:

http://blogs.sun.com/arungupta/entry/screencast_web6_first_jruby_app

Posted by Arun Gupta on August 23, 2007 at 01:11 AM PDT #

Drop this WAR file in "domains/domain1/autodeploy" directory of your GlassFish instance and you are done!

Posted by laptop batteries on November 26, 2008 at 01:53 PM PST #

Hi,

Thanks for your work. I followed your screencast but when I deploy the application to glassfish and browse to the the app, i get my rails app directory listing? Can someone help?

Posted by LL on November 28, 2008 at 02:03 PM PST #

Have you tried the recent screencast at: http://blogs.sun.com/arungupta/entry/screencast_26_develop_run_debug ?

-Arun

Posted by Arun Gupta on December 01, 2008 at 01:02 AM 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