Pramod published an updated JRuby Gem for GlassFish v3. Download the gem here.
Here are the updates from last time:
- The Gem is now smaller – 2.4 MB instead of 2.9 MB (approx 20% smaller).
- The Gem is now using the latest v3 codebase, including Grizzly JRuby module 1.6.1.
- 2 Rails instances are created instead of the default one. So now 2 requests can be invoked in parallel and they both will be served instead of returning a blank page for the pending request. This explains/resolves the issue reported here.
- The list of known issues is now available
- #3856 – Default Rails page gives 404
- #3964 – Option to specify port at the command-line
- #3965 – Port conflict should be resolved transparently
- #3966 – Blank page returned if no Rails instance is available
- #3968 – Provide a means to configure number of Rails instances
- #3971 – Usage of v3 gem needs to be consistent with WEBrick
Please file bugs if you see any other issues.
Ad of course, you can BYOG (Build Your Own Gem
Either way, once the Gem is installed then go ahead and use it as described below:
- Create a template app as:
jruby -S rails hello - Create a controller and view as:
cd hello
jruby script/generate controller say hello - Edit controller as:
vi app/controllers/say_controller.rband add the following variable in hello helper method:
@hello_string = "v3 Gem is getting polished!" - Edit view as:
vi app/views/say/hello.rhtmland add the following string at the bottom:
<%= @hello_string %> - Ad deploy the application on GlassFish v3 gem as:
cd ..
jruby -S glassfish_rails hello
That’s it! The following output in the console confirms successful start of the Gem:
Jan 4, 2008 3:35:52 PM com.sun.grizzly.standalone.StaticResourcesAdapter <init>
INFO: New Servicing page from: /Users/arungupta/testbed/r126/jruby-1.0.3/bin/hello/public
Jan 4, 2008 3:36:00 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: Startup service : Application Loader
Jan 4, 2008 3:36:00 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: Startup service : Grizzly on port 8080
Jan 4, 2008 3:36:00 PM com.sun.enterprise.v3.server.AppServerStartup run
INFO: Glassfish v3 started in 8567 ms
The application is deployed at http://localhost:8080/hello/say/hello and shows the output as:

And http://localhost:8080/hello is displayed in the browser as shown below:

And you can try more advanced applications like Mephisto as described here.
Technorati: ruby jruby glassfish v3 gem
Related posts:- BitNami’s JRubyStack = JRuby + Rails + GlassFish Gem + MySQL all bundled together
- JRuby-on-GlassFish Update Center Module – Now Updated with JRuby 1.0.2
- TOTD #24: Getting Started with Rails 2.0.x in JRuby 1.0.3 and JRuby 1.1RC1
- JRuby 1.1.3 released – Getting Started with GlassFish
- First JRuby on Rails App in GlassFish V3
Hi Arun,
I can’t have glassfish running multiple concurrent requests:
Try this please:
rails concurrent
cd concurrent
script/generate controller test test
edit app/controllers/test.rb
class TestController < ApplicationController
def test
sleep 10
@value = Time.now
end
end
edit app/views/test/test.test.html.erb
<%= @value %>
edit config/database.yml
production:
adapter: jdbcsqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
Now launch glassfish gem in production mode:
jruby -S glassfish -e production -n 4 –runtimes-min 4 –runtimes-max 4
Now I try (concurrently) get 4 times the page:
http://localhost:3000/test/test
I receive the results queued (the last result after 40 seconds) seems that glassfish gem cannot handle multiple concurrent requests on multiple separate instances of jruby…
What do you think about this issue ?
May be I’m doing something wrong ?
Comment by Tex — August 24, 2009 @ 2:39 am