« Previous day (Sep 17, 2007) | Main | Next day (Sep 19, 2007) »
http://blogs.sun.com/pramodg/date/20070918 Tuesday September 18, 2007

JRuby Updatecenter module for Glassfish V2

JRuby Updatecenter module for Glassfish V2

With the official release of GlassFish V2, I wanted to inform you all about the availability of a new GlassFish update center module to support JRuby. This module is called "JRuby on GlassFish". This module will make it is easier to deploy a Ruby on Rails (ROR) application to a GlassFish application server. Thanks to Rajeshwar, who actually pushed the module on the net.


Contents of the JRuby module

This JRuby update center module primarily consists of JRuby 1.0.1 and Goldspike (nee Rails Integration) revision 735. The JRuby 1.0.1 source bits that are part of this module, have been updated with the following gems :



Installing the JRuby on GlassFish module

Let us refer to GlassFish root directory location as $GLASSFISH_ROOT for the course of this blog. After installing GlassFish V2 run the Update Center client

  $GLASSFISH_ROOT/updatecenter/bin/updatetool

Then you should see "JRuby on GlassFish" as one of the available modules.



Accept the license agreement to install this module. After the successful installation of this module, you would see a new directory "jruby-1_0" created under your GlassFish root directory. A screenshot of the JRuby module directory


The top level directory name (jruby-1_0) corresponds to the version of the update center module e.g. for the 1.0 version of the updatecenter, the top level directory is named jruby-1_0. Subsequent release of the updatecenter module would have different version number and corresponding different directory name.


Web application modes
Since this JRuby update center module contains GoldSpike (nee Rails Integration) we also support the 2 modes - "Standalone" and "Shared", of deploying a RubyOnRails (ROR) application to a GlassFish application server instance. Additionally for this blog we would be using the directory deployment feature of GlassFish.
Post Installation steps
If you plan to use the "Shared" mode you would have to perform one additional step. After the successful installation of the JRuby update center module copy the required libraries to the GlassFish library directory and restart the GlassFish application server instance (for these libraries to be picked up by the running instance). The commands to be used are :
    asadmin stop-domain domain1    (Stop the application server if it is running)
    cp $GLASSFISH_ROOT/jruby-1_0/jruby-1.0.1/lib/jruby-complete.jar $GLASSFISH_ROOT/lib
    cp $GLASSFISH_ROOT/jruby-1_0/goldspike/target/goldspike-1.4-SNAPSHOT.jar $GLASSFISH_ROOT/lib
    cp $GLASSFISH_ROOT/jruby-1_0/goldspike/target/commons-pool-1.3.jar $GLASSFISH_ROOT/lib
    asadmin start-domain domain1   (Start the application server instance)

Deploy and run an application (Shared mode)
Now lets look at the steps that are required to deploy an application to GlassFish in the "Shared" mode. Ensure that you have followed the steps listed under the section "Post Installation steps".
For the purpose of this blog lets use the "helloworld-1.2.3" sample present under $GLASSFISH_ROOT/goldspike/samples directory. Execute these steps to get the helloworld-1.2.3 sample deployed :
    cd $GLASSFISH_ROOT/jruby-1_0/goldspike/samples/helloworld-1.2.3
    ant -f $GLASSFISH_ROOT/jruby-1_0/install.xml create-shared 
    cd ..
    asadmin start-domain
    (If the application server is already running this command would safely exit)
    asadmin deploy helloworld-1.2.3

From a browser access the web page : http://localhost:8080/helloworld-1.2/welcome
which would result in the following html page being displayed



Deploy and run an application (Standalone mode)
If you are planning to use the "Standalone" mode of WAR creation, you do not have to do the Post Installation steps. After the update center module has been successfully installed you could directly start using it w/o any restart of the GlassFish application server instance. The steps to be followed are :
    cd $GLASSFISH_ROOT/jruby-1_0/goldspike/samples/helloworld-1.2.3
    ant -f $GLASSFISH_ROOT/jruby-1_0/install.xml create-standalone 
    cd ..
    asadmin start-domain
    (If the application server is already running this command would safely exit)
    asadmin deploy helloworld-1.2.3

From a browser access the web page : http://localhost:8080/helloworld-1.2/welcome

You would notice the only difference is the ant task that you specify - "create-shared" or "create-standalone".
The "create-shared" task -
The "create-standalone" task -

Posted by pramodg [Sun] ( September 18, 2007 10:44 AM ) Permalink | Comments[7]