Wednesday Feb 13, 2008

GlassFish v3 Gem - 0.1.1 available

Pramod released an updated version 0.1.1 of the JRuby GlassFish v3 gem.

What's New ? - Mainly alignment with Rails convention
  1. The name of the gem is changed from "GlassFish" to "glassfish".
  2. The default port number is 3000.
  3. Applications are deployed at root context ("/"). So the default application is now deployed "http://localhost:3000/home/index" instead of "http://localhost:8080/temp/home/index".
And then there are some other improvements:
  1. The number of concurrent requests can now be set using a command-line argument (instead of "-J-Djruby.runtime"). So 2 Rails instances can be created using the following command:

    jruby -S glassfish_rails temp -n 2
  2. Rails instances are created in parallel to improve the startup time of the gem.
How to install it ?

If you installed 0.1.0 version of the gem, then you need to uninstall using the following command:

bin/jruby -S gem uninstall GlassFish
Successfully uninstalled GlassFish-0.1.0-java
Remove executables and scripts for
'glassfish_rails, asadmin, asadmin.bat' in addition to the gem? [Yn]  Y
Removing glassfish_rails
Removing asadmin
Removing asadmin.bat

And then install the new gem using the following command:

bin/jruby -S gem install glassfish
JRuby limited openssl loaded. gem install jruby-openssl for full support.
Successfully installed glassfish-0.1.1-universal-java
1 gem installed

And for a fresh check out of JRuby trunk, here is the list of gems shown:

bin/jruby -S gem list

\*\*\* LOCAL GEMS \*\*\*

actionmailer (2.0.2)
actionpack (2.0.2)
activerecord (2.0.2)
activeresource (2.0.2)
activesupport (2.0.2)
glassfish (0.1.1)
rails (2.0.2)
rake (0.8.1)
sources (0.0.1)

Read more details about the this newly released gem here.

All the latest information about the gem can be found at GlassFish JRuby wiki or JRuby wiki.

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 rubyonrails

Thursday Feb 07, 2008

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 Now it has found a permanent home on 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
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

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


« June 2016