GlassFish v3 Ruby Gem - New Home on RubyForge

Ruby Forge Icon GlassFish v3 Gem allows JRuby-on-Rails application to be launched in GlassFish v3 server. It provides a robust alternative to WEBrick and Mongrel for development and deployment of your JRuby-on-Rails applications.

UPDATE (Feb 14): A 0.1.1 version of the gem is released which will change the installation process.

The Gem was originally announced here and then updated here. All along, the Gem was living a nomadic life on download.java.net. Now it has found a permanent home on http://rubyforge.org/projects/glassfishgem/. We are excited to release version 0.1.0 of Gem co-located with other standard gems such as RubyGems, Rails and RMagick. This new and permanent home provides a much more seamless installation of v3 gem. Here are the highlights:
  • The Gem replaces WEBrick as the development container and a pack of Mongrels front-ended by light-weight Web server + Capistrano for management by one command and one process (think "eco-friendly").
  • Works with both JRuby 1.0.3 and JRuby 1.1RC1.
  • Multiple applications can be deployed in one instance of gem, each in their own context root and running on separate ports (details below).
  • Each application can serve multiple requests concurrently. This can be configured by the number of JRuby runtimes using -J-Djruby.runtime as a command-line property (details below).
  • The applications deployed on this Gem can easily make use of pooled resources such as database connections as explained in TOTD #9.
  • The released version is 0.1.0. Even though a preview version of Gem was released earlier, the version number is starting from scratch because of the newly found permanent home. 
  • Installing the Gem is a seamless and integrated process as explained below.
How to install the Gem ?

After you've downloaded and unzipped JRuby 1.0.3, go to JRUBY_HOME directory and install the gem by giving the following command:

bin/jruby -S gem install GlassFish
Need to update 24 gems from http://gems.rubyforge.org
........................
complete
Select which gem to install for your platform (java)
 1. GlassFish 0.1.0 (java)
 2. Skip this gem
 3. Cancel installation
> 1
Successfully installed GlassFish-0.1.0-java


Once the gem is installed, "glassfish_rails" script is available in JRUBY_HOME/bin directory. The exact same commands work for installing the gem in JRuby 1.1RC1 as well.

How to deploy an application on Gem ?

TOTD #24 shows how to develop a JRuby-on-Rails applications with JRuby 1.0.3 and JRuby 1.1 RC1 and tested using WEBrick. To deploy these applications on the newly installed gem, use the following command:

cd .. (go to parent directory of the application)
jruby -S glassfish_rails hello


Now the app is deployed at "http://localhost:8080/hello/say/hello".

How to configure the number of concurrent requests ?

The default number of concurrent requests that can be handled by an application deployed Gem is 1. If your application hosted on the Gem needs to handle concurrent requests then you need to specify the command-line option "-J-Djruby.runtime=NNN", where NNN is the number of expected concurrent requests. For example, if your application needs to handle 4 concurrent requests then the command to host your application will look like:

jruby -J-Djruby.runtime=4 -S glassfish_rails hello

How to host multiple applications ?

Multiple applications can be hosted on GlassFish gem by modifying the default port number on which the Gem is started. The ports that need to be changed are: "http-listener-1", "http-listener-2" and "admin-listener".

For now, the port numbers need to be modified by manually editing "jruby-1.0.3/lib/ruby/gems/1.8/gems/GlassFish-0.1.0-java/domains/domain1/config/domain.xml" file. Search for the string in first column, replace the port attribute of that XML element with the value in second column and the third column shows the default value:

Search String New Port Default
http-listener-1 8081 8080
http-listener-2 8182 8181
admin-listener 4849 4848

Any subsequent application deployed on GlassFish gem will now be hosted on http://localhost:8081/<context-root>/<controller>/<view> where <context-root> is the name of your Rails application.

A command-line switch, similar "-J-Djruby.rutime" will be provided in the near future.

Please use the gem and send us feedback on GlassFish forums, dev@glassfish or gem mailing list.

File issues in JIRA or GlassFish Issue Tracker.

Technorati: ruby jruby glassfish v3 gem rubyforge
Comments:

Congrats on the new release - GlassFish is looking more and more like the best place to deploy Rails.

Posted by Brian Ketelsen on February 07, 2008 at 10:23 PM PST #

Is it possible to set the Rails environment variable from the command line or in some other fashion?

Posted by Walter on February 07, 2008 at 11:44 PM PST #

Excellent Arun. Is it possible to deploy to the "/" context root?

Posted by Rich Manalang on February 08, 2008 at 01:42 AM PST #

Rich, it seems that the current version of the gem and glassfish doesn't support "/" context root yet. I hope that this will be implemented soon.

More info:
http://archive.jruby.codehaus.org/user/C937E857-2D66-48F2-A4DC-7F20E76A10C4@gmail.com
https://glassfish.dev.java.net/issues/show_bug.cgi?id=3885

Posted by Igor Minar on February 09, 2008 at 06:54 AM PST #

[Trackback] acts_as_conference Day 2 started with breakfast ... yaaay! I had to hunt for breakfast yesterday. Robert started the day by asking some questions and here are the responses: 100% will come back if organized next year Fri/Sat is good $100...

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

Is there anything else needed to get this working on Leopard?

I've been experiencing the same problems described in:
http://jira.codehaus.org/browse/JRUBY-1922

Any thoughts on how to fix this?

Thank you.

Posted by diana on February 10, 2008 at 11:38 PM PST #

Thanks Brian, we do want to make GlassFish as the premier platform for deploying Rails applications.

Rich, Igor already provided the bug # (3885). We are already working on it so an updated version of the gem will be available soon.

Diana, I tested this gem on Leopard and it worked without any issues. I tried it several times on different machines last week and it worked every time. The bug number you mentioned is on Windows. Can you tell me what is your environment ?

Please send feedback to users@glassfish.dev.java.net.

Posted by Arun Gupta on February 11, 2008 at 03:46 AM PST #

Arun,
I was trying to deploy HelloWorldRailsApp from the samples in glassfissh v2, and since this directory contains a WEB-INF folder it seemed
that I was deploying a .war file.

It does work now without any other special settings.

Thank you.

Posted by diana on February 11, 2008 at 04:19 AM PST #

Walter, I filed https://glassfish.dev.java.net/issues/show_bug.cgi?id=4156 for specifying Rails environment variable.

Posted by Arun Gupta on February 11, 2008 at 04:26 AM PST #

Arun,

I saw the same problem as Diana mentioned. If your app contains WEB-INF dir, glassfish thinks that this is a java web app and tries to deploy it as such. The glassfish gem should ignore WEB-INF dir when the app is not deployed as war.

cheers,
Igor

Posted by Igor Minar on February 11, 2008 at 05:03 AM PST #

Igor, can you file a bug for this ?

-Arun

Posted by Arun Gupta on February 11, 2008 at 09:41 AM PST #

[Trackback] Pramod released an updated version&nbsp;0.1.1 of the JRuby GlassFish v3 gem. What's New ? - Mainly alignment with Rails convention The name of the gem is changed from "GlassFish" to "glassfish". The default port number is 3000. Applications are...

Posted by Arun Gupta's Blog on February 13, 2008 at 10:53 PM PST #

Hi Arun,

Given the options of managing a pack of jmongrels or glassfish for a JRuby app, glassfish sounds like the way to go. The question is timing. What is your opinion of using this in a production environment versus jmongrels? If you think that's a little crazy right now, do you have a timeline when it would be ready for production?

Posted by Bob on February 18, 2008 at 01:04 AM PST #

Bob, there is at least one instance where gem is used for a live app. Read more about that at:

http://glassfish.kr/pages/816824

Can you define what you mean by a production environment ? So far the only support is using forums & aliases.

Posted by Arun Gupta on February 19, 2008 at 10:11 AM PST #

I'm not so worried about support at this point but more about the "readiness" of the code to be run in a production environment. It would be a Beta environment so there would be limited live users that could use the system 24x7 but not the expectation that there's no hiccups. However in the April/May timeframe it would be rolled out to all users. Is there a Glassfish V3 target shipping date?

Posted by bob on February 19, 2008 at 12:37 PM PST #

Bob,

v3 draft schedule is available at: http://wiki.glassfish.java.net/Wiki.jsp?page=GlassFishV3Schedule. The final version of gem will be aligned with v3 FCS as well but we expect the gem to be in fairly stable shape by the TP2 release currently scheduled for late April. I'll recommend to perform testing with gem in your environment and let us know if there are any issues. It would be helpful to know more details about your app architecture, load details etc. Send me an email at arun dot gupta at sun dot com.

Posted by Arun Gupta on February 19, 2008 at 12:45 PM PST #

[Trackback] Pramod announced the release of GlassFish v3 Gem ver 0.1.2. The focus of this release is bugfixes: IssueTracker #4228: Duplicate entries for Scaffold generated by Rails 2.0.2 IssueTracker #3966: Blank page returned if no Rails instance is available Ru...

Posted by Arun Gupta's Blog on March 13, 2008 at 01:23 PM PDT #

[Trackback] Vivek released 0.3.0 version of GlassFish Gem for Rails (a total of 11 issues fixed and resolved - RubyForge &amp; GlassFish Issue Tracker) earlier. But&nbsp;that caused a regression on #4228. And so matching the agility expected by Rails developers, h...

Posted by Arun Gupta's Blog on June 24, 2008 at 11:42 PM 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