Vivek released 0.3.0 version of GlassFish Gem for Rails (a total of 11 issues fixed and resolved – RubyForge & GlassFish Issue Tracker) earlier. But that caused a regression on #4228. And so matching the agility expected by Rails developers, he quickly released 0.3.1. And a wee bit smaller too – 2.68MB for 0.3.1 instead of 2.69MB for 0.3.0.
If you have an existing version of the gem, then you just need to update it:
| ~/testbed/jruby-1.1 >bin/jruby -S gem update glassfish -r JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Updating installed gems… Bulk updating Gem source index for: http://gems.rubyforge.org Attempting remote update of glassfish Successfully installed glassfish-0.3.1-universal-java 1 gem installed Gems updated: glassfish |
If the gem has never been installed, then you install it as:
| ~/testbed/jruby-1.1.2 >bin/jruby -S gem install glassfish JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed glassfish-0.3.1-universal-java 1 gem installed |
And make sure next time you have to update the gem instead of installing from scratch
For that, just install the gem this time and let us know your feedback on GlassFish Webtier Forum or Webtier Alias. If any of your Rails application do not work then please file bugs at GlassFish Issue Tracker (“V3″ as “Found in Version:” and “jruby” as “Subcomponent:”).
The gem installation may require to set “JAVA_MEM=-Xmx800m” because of the growing memory requirements. Otherwise you may get “Exception in thread “main” java.lang.OutOfMemoryError: Java heap space“.
Try a simple scaffold application to see the output as shown below:

The startup output in the gem console (output from GlassFish) is:
| ~/testbed/jruby-1.1.2/samples/rails >../../bin/jruby -S glassfish_rails runner Jun 24, 2008 11:04:51 PM com.sun.enterprise.glassfish.bootstrap.ASMain main INFO: Launching GlassFish on HK2 platform Jun 24, 2008 11:04:51 PM com.sun.enterprise.glassfish.bootstrap.ASMainHK2 findDerbyClient INFO: Cannot find javadb client jar file, jdbc driver not available Jun 24, 2008 11:04:52 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start INFO: Listening on port 3000 Jun 24, 2008 11:04:52 PM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL WARNING: pewebcontainer.all_ssl_protocols_disabled Jun 24, 2008 11:04:52 PM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL WARNING: pewebcontainer.all_ssl_ciphers_disabled Jun 24, 2008 11:04:52 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start INFO: Listening on port 3131 Jun 24, 2008 11:04:52 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start INFO: Listening on port 3838 Jun 24, 2008 11:04:52 PM com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setContextRoot INFO: Admin Console Adapter: context root: /admin Jun 24, 2008 11:04:52 PM com.sun.grizzly.jruby.RailsAdapter startRubyRuntimePool INFO: Starting Rails instances Jun 24, 2008 11:04:58 PM SEVERE: JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Jun 24, 2008 11:04:59 PM com.sun.grizzly.jruby.RubyObjectPool$1 run INFO: JRuby and Rails instance instantiation took : 6600ms Jun 24, 2008 11:04:59 PM org.glassfish.scripting.rails.RailsDeployer load INFO: Loading application runner at / Jun 24, 2008 11:04:59 PM com.sun.enterprise.v3.server.AppServerStartup run INFO: Glassfish v3 started in 7945 ms |
and then the console is updated as more entries are added (output from Rails):
| Jun 24, 2008 11:05:25 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Processing DistancesController#index (for 0:0:0:0:0:0:0:1%0 at 2008-06-24 23:05:25) [GET] Jun 24, 2008 11:05:25 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Session ID: BAh7ByIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo SGFzaHsABjoKQHVzZWR7ADoMY3NyZl9pZCIlNTdhMGYxNjkxOTk5ZjI1ZjI4 OGZjODZjZjcxN2QyNzQ=–cbf4578767e5887d4b62bd249e7624dcb7d1cf90 Jun 24, 2008 11:05:25 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Parameters: {“cont roller”=>”distances”, “action”=>”index”} Jun 24, 2008 11:05:25 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: WARNING: You’re using the Ruby-based MySQL library that ships with Rails. This library is not suited for production. Please install the C-based MySQL library instead (gem install mysql). Jun 24, 2008 11:05:25 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: SQL (0.001000) SET NAMES ‘utf8′ Jun 24, 2008 11:05:25 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: SQL (0.001000) SET SQL_AUTO_IS_NULL=0 Jun 24, 2008 11:05:25 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Distance Load (0.003000) SELECT * FROM `distances` Jun 24, 2008 11:05:25 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Rendering template within layouts/distances . . . Jun 24, 2008 11:05:48 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Parameters: {“authenticity_token”=>”519436f2248515d901051acafe0726dfd88746f0″, “distance”=>{“miles”=>”4″, “run_at(1i)”=>”2008″, “run_at(2i)”=>”6″, “run_at(3i)”=>”24″, “run_at(4i)”=>”07″, “run_at(5i)”=>”00″}, “commit”=>”Create”, “controller”=>”distances”, “action”=>”create”} Jun 24, 2008 11:05:48 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Distance Columns (0.009000) SHOW FIELDS FROM `distances` Jun 24, 2008 11:05:48 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: SQL (0.000000) BEGIN Jun 24, 2008 11:05:48 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Distance Create (0.000000) INSERT INTO `distances` (`miles`, `run_at`, `created_at`, `updated_at`) VALUES(4.0, ’2008-06-24 14:00:00′, ’2008-06-25 06:05:48′, ’2008-06-25 06:05:48′) Jun 24, 2008 11:05:48 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: SQL (0.002000) COMMIT . . . Jun 24, 2008 11:06:09 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Parameters: {“authenticity_token”=>”519436f2248515d901051acafe0726dfd88746f0″, “distance”=>{“miles”=>”3.5″, “run_at(1i)”=>”2008″, “run_at(2i)”=>”6″, “run_at(3i)”=>”23″, “run_at(4i)”=>”06″, “run_at(5i)”=>”55″}, “commit”=>”Create”, “controller”=>”distances”, “action”=>”create”} Jun 24, 2008 11:06:09 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Distance Columns (0.015000) SHOW FIELDS FROM `distances` Jun 24, 2008 11:06:09 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: SQL (0.000000) BEGIN Jun 24, 2008 11:06:09 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Distance Create (0.000000) INSERT INTO `distances` (`miles`, `run_at`, `created_at`, `updated_at`) VALUES(3.5, ’2008-06-23 13:55:00′, ’2008-06-25 06:06:09′, ’2008-06-25 06:06:09′) Jun 24, 2008 11:06:09 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: SQL (0.001000) COMMIT Jun 24, 2008 11:06:09 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Redirected to http://localhost:3000/distances/5 . . . Jun 24, 2008 11:06:10 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Parameters: {“controller”=>”distances”, “action”=>”index”} Jun 24, 2008 11:06:10 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Distance Load (0.003000) SELECT * FROM `distances` Jun 24, 2008 11:06:10 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Rendering template within layouts/distances Jun 24, 2008 11:06:10 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Rendering distances/index Jun 24, 2008 11:06:10 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Distance Columns (0.008000) SHOW FIELDS FROM `distances` Jun 24, 2008 11:06:11 PM com.sun.grizzly.jruby.RailsAdapter$Logger log INFO: Completed in 0.05900 (16 reqs/sec) | Rendering: 0.03200 (54%) | DB: 0.01100 (18%) | 200 OK [http://localhost/distances] |
Redmine seems to have issues with Rails 2.1. I’ll play with some other applications later. But have you tried deploying your Rails application on GlassFish gem ? As mentioned above, let us know your feedback on GlassFish Webtier Forum or Webtier Alias and file bugs on GlassFish Issue Tracker.
Details about previous versions are available at 0.2.0, 0.1.2, 0.1.1, 0.1.0.
Technorati: glassfish v3 rubyonrails jruby ruby gem
Related posts:- BitNami’s JRubyStack = JRuby + Rails + GlassFish Gem + MySQL all bundled together
- TOTD# 36: Writing First Test for a Rails Application
- Rails 2.1 on GlassFish – it works!
- TOTD # 72: JRuby and GlassFish Integration Test #3: JRuby 1.2.0 RC2 + Rails 2.2.x + GlassFish v3
- TOTD # 71: JRuby and GlassFish Integration Test #2: JRuby 1.2.0 RC1 + Rails 2.2.x + GlassFish v3 Prelude
[Trackback] Substruct is an open-source E-Commerce project written using Ruby-on-Rails framework. It provides a simple e-commerce platform, content management system and customer response system – all in one. I found out about this application from Sang "Passion"…
Comment by Arun Gupta's Blog — June 30, 2008 @ 11:05 am
[Trackback] The default database for Rails 2.0.x application is SQLite3. This database is bundled with Mac OSX Leopard and so makes it really easy to get started with Ruby-on-Rails. But it requires couple of additional steps if you are using JRuby….
Comment by Arun Gupta's Blog — July 2, 2008 @ 6:24 am
Thanks for your detailed tips.
I installed jruby-1.1.3 and glassfish 0.3.1 (sorry – I had to install from scratch
and my micro example worked fine.
So I tried to launch my own (somewhat bigger) project with jruby and glassfish (11 models, 13 controllers, 3 plugins [attachment_fu, open_id_authentication, restful-authentication]) – and with just a minor glitch – it worked.
I noticed that I have to change my database config to:
development:
adapter: jdbcsqlite3
database: projecttracker/db/development.sqlite3
timeout: 5000
And that was it.
2 questions:
a) Is there a way to detect the glassfish environment in ruby/rails -> so that I could dynamically add the additional path to the development.sqlite3 file? (Not needed for standalone DBs
b) Is there a way to package my application into a WAR file and deploy only this WAR file on a glassfish (v3) server?
Comment by Rene A. — July 27, 2008 @ 12:07 pm
Rene,
I believe a) happens only for SQLite3. Can you file an RFE at:
https://glassfish.dev.java.net/issues/enter_bug.cgi?issue_type=ENHANCEMENT
using "jruby" sub-component ?
Yes, Rails application can be easily bundled into a WAR file as described at:
http://blogs.sun.com/arungupta/entry/war_based_packaging_and_deployment
In fact this is a very popular option that s used for deployment.
Comment by Arun Gupta — July 28, 2008 @ 4:38 pm
Hi Arun,
firstly: many thanks for your efforts in providing a stable deployment solution for the JRuby on Rails environment: your job is already great and will be surely better in future releases!
Said that, i have migrated from glassfish gem 0.2 to 0.3 and noticed that the AS also log response return messages into the views of my application.
This does not happens always, but when it does affects both normal HTTP requests and Ajax requests (for example i see the response status into the in-place-editor fields).
A logging string example:
HTTP/1.1 200 OK Content-Type: text/html; charset=iso-8859-1 Transfer-Encoding: chunked Date: Tue, 29 Jul 2008 07:34:43 GMT
Any idea on how to remove this logging?
Thank you again and greetings.
Michele
Comment by Michele Costa — July 29, 2008 @ 12:36 am
Rene, Filed https://glassfish.dev.java.net/issues/show_bug.cgi?id=5404 to track your issue.
Comment by Arun Gupta — July 30, 2008 @ 9:38 am