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.
« jMaki, NetBeans and... | Main | Marthon - Good and... »

http://blogs.sun.com/arungupta/date/20070515 Tuesday May 15, 2007

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

del.icio.us | furl | simpy | slashdot | technorati | digg
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 03:22 PM 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 09: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 05:04 PM 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 13, 2007 at 05:01 AM PDT #

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

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

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 23, 2007 at 06:49 AM 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 07: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 08:11 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
« jMaki, NetBeans and... | Main | Marthon - Good and... »

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 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 windows wsaddressing wsit
Project Tango: Adding Quality of Service and .NET Interoperability to the Metro Web Services Stack
Locations of visitors to this page

calendar

« May 2008
SunMonTueWedThuFriSat
    
11
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
       
Today

Stats

Today's Page Hits: 7046


Total # blog entries: 598
Total # comments: 1643

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

Last 50