1 2 3 Previous Next


62 posts

GlassFish v3 is out now. This release brings in expanded and mature suport for dynamic languages based frameworks, such as Ruby on Rails, Django, Grails and Lift. 

Here is a quick update:

Ruby on Rails

GlassFish v3 is Ruby aware. It ships with JRuby container to host Ruby Rack applications. We have made lots of improvements in our Ruby support and make GlassFish run it faster. See Eileen's blog on JRuby performance tuning on GlassFish v3.

  • Robust support for Rails, Merb, Sinatra work out of the box.
  • Full Rack compliance
  • Run any Rackup script to hook in any Rack based framework
  • Administration and Monitoring using asadmin CLI or Admin console
  •     See how would you go about monitoring and administration of Ruby on Rails or an Rack based application.    
  • Many bug fixes

Python and Django

Python and Django applications can be deployed just like Ruby applications. See a blog posting on running Django application on GlassFish.
  • More bug fixes to Jython container
  • Jython container can be obtained from GlassFish UpdateCenter
    $ glassfishv3/bin/updatetool
        Jython UpdateTool     



Due to resource constraints and some technical issues some of the planned features could not be implemented. Here is a quick summary.

  • Grails production war works OOB
  • shared-war not supported in Grails 1.x
  •         For shared-war to work with Grails 1.x JIRA issues 5174 and 5175 need to be addressed in Grails. You can follow the development at GlassFish IT 6459.        
  • run-app does not run with Embedded GlassFish. There have been some issues and at some point in time in the future it will be implemented. 

We are definitely looking out to the community to help us improve GlassFish to be the best platform to support all Grails features.




Scala and Lift produced WAR file works well on GlassFish v3. We need to make more progress on working with Lift community to include embedded GlassFish maven plugin to include in the Lift archetype generated maven pom file.

This is 1.0.0 release of GlassFish gem. This release is based on GlassFish v3 final release. Unlike other gem releases which used to get posted on the RubyForge gem repo. Now its pushed to Gemcutter. The end result is pushing is easy and the gem is available moments after its pushed. Also now I can see how many of each release get downloaded.

To install, simply type the following on a JRuby installation:

$ gem install glassfish

New features in this release

  • Implemented using GlassFish v3 embedded API.
  • Startup time improvement. Almost 15-18% faster startup.
  • Full Rack compliance
  • Support for running GlassFish gem by passing code block

     GlassFish::Server.start(:address=>"", :port=>4000) do

       use Rack::CommonLogger

       use Rack::ShowExceptions

       map "/hello" do

         use Rack::Lint

         run Proc.new {[200, {"Content-Type" => "text/html"}, "Hello"]}


In the code above, GlassFish is started on port 4000 and it binds to port After it starts up and when the first request arrives it runs the given code block. The code block is using Rack middlewares such as CommonLogger and ShowException for better debugging during development. The actual Rack application code is minimalistic which returns "Hello" as content body with HTTP status code 200 and HTTP header ContentType.
  • Lots of fixes for Sinatra support (extensions, middleware etc.)
  • New -a CLI switch to bind to a given IP address
  • Improved support for running Rackup scripts   
  • Grizzly (NIO based HTTP library) configuration thru glassfish.yml
          $ gfrake config

          Below is the default Grizzly configuration for GlassFish gem.

Grizzly Config


Bug fixes  

25812  ActionController::Request.remote_ip is not set
26147  Setting Hostname IP Address Incorrectly
26149  Glassfish Gem fails to load Rails application in the production environment
26208  Can't get glassfish to start rails in thread-safe mode
26821  Error when running rack app
26866  JVM crash probably due to log file running over limit
26935  rack.run_once not getting set
27030  Extending CLASSPATH poisons glassfish gem?
27125  Application Environment not passed to Sinatra

Checkout the release notes and as always keep using it and send us feedback either at RubyForge or to users@glassfish.dev.java.net


GlassFish v3 final has monitoring and administration support for Ruby on Rails or any Ruby Rack based application. Here is how you would go about administering and monitoring your Ruby on Rails application on GlassFish v3:


GlassFish v3

First you need to install GlassFish v3. Get it from here. After the download simply unzip it to the directory of your choice.


Install JRuby 1.4.0 using updatetool

$ /tools/glassfishv3/bin/updatetool

Select JRuby 1.4.0 and click install. JRuby along with Rails 2.3.5, Merb, MySQL JDBC adapters will be installed inside glasfishv3/GlassFish/jruby. Now add it to your path.

$ export JRUBY_HOME=/tools/glasfishv3/GlassFish/jruby

Install JRuby 1.4.0 from jruby.org

Alternatively you can install JRuby form jruby.org. You would also need to install any gem that your application will depend on, such as Rails, Merb, Sinatra or simply Rack incase you are writing your own Rack based framework. You would setup JRUBY_HOME and PATH accordingly.


Before you begin, first start GlassFish v3 server

$ glassfishv3/bin/asadmin start-domain


In case you are using your own JRuby installation then you need to tell GlassFish where to find it. There are 2 ways you can do it. Using asadmin CLI or using Admin console.

asadmin CLI

$asadmin configure-jruby-container --jruby-home=/tools/jruby-1.4.0

Admin console

In your browser type: http://localhost:4848, then select Configure=>Ruby container and then enter JRuby instalation in JRuby Home field and click Ok.

Ruby Container configuration

JRuby Runtime Pool

You can also setup JRuby runtime pool if you chose to run Rails or any other Ruby framework in non-threadsafe mode. This setting is recommended to be used only for production and for most optimal performance its advised to keep the initial, min and max values same. Basically freeze the pool so that it does not auto adjust between min and max values. Creation of JRuby runtime is a very expensive process, both in terms of time and resources, so you want to be careful with that specially in production uses. You can use the same screen where you setup JRuby Home to configure the runtime pool settings.

Here is how you can  configure JRuby runtime pool using asadmin CLI

$ asadmin configure-jruby-container --jruby-runtime=2 --jruby-runtime-min=2 --jruby-runtime-max=2


GlassFish v3 monitoring infrasutructure lets each of the container define their own set of probes and expose these as dTrace or view the stats using container exposed statistics or you can write javscript code and use the monitoring REST based services to collect the stats of your choice. For details on GlassFish v3 monitoring see Prashant's excellent blog.

asadmin CLI

Here is how you can configuring monitoring for Ruby applications using asadmin CLI

$ asadmin configure-jruby-container --monitoring=true

Setting --monitoring to false will simply disable it.

Admin console

Ruby monitoring configuration

Develop a Ruby application

Now that you have installed GlassFish v3 and JRuby and configured the JRuby container, runtime pool etc. Its time to develop a Ruby web application. To keep this blog simple, I would go for an extremely simple Rackup script config.ru.


class HelloWorld
  def call(env)
    [200, {"Content-Type" =>"text/plain"}, ["Hello world!"]]
run HelloWorld.new

In the above code HelloWorld class is a Rack application. A Rack application is the one that responds to call and returns array of HTTP status code, HTTP headers and the content. HelloWorld simply returns "HelloWorld!" as the content body.

Now lets deploy it.


Assuming you are in the directory where config.ru file is located. Do the following to deploy on GlassFish:

$ asadmin deploy .

If you want to deploy using some other version of JRuby, lets say you have JRuby 1.5.0.dev and want to deploy using this version of JRuby, this is what you would do:

$ asadmin deploy --property jruby.home=/tools/jruby-1.5.0.dev .

If you don't like doing it using asadmin CLI, you can use admin console as well. Simply login to http://locahost:4848/ and chose applications node and on deployment screen chose applicaton type as Ruby Application. See the image below

Ruby Deployment

Now Run...

Now access the application at http://localhost:8080/rack/


monitoring stats

In earlier step we have already enabled monitoring so now you can use JConsol or Admin console or use asadmin CLI to monitor the stats. You can also use dTrace as well. Let see how you would use Admin console to monitor your stats. Go to http://localhost:4848/ and select Enterprise Server and then Monitor tab. You should see different stats such as JRuby Runtme Pool, HTTP and JRuby container stats.

Monitoring 1

Go get GlassFish v3 and start running, monitoring your Ruby on Rails or Merb or Sinatra or any Rack application. Send us your comments at users@GlassFish.dev.java.net.

The slides for my JavaOne technical session: Dynamic Languages Powered by Glassfish are available here.

Filter Blog

By date: