JRuby 1.1.3 was released last week – download here. The highlights are:
- 82 issues resolved since JRUby 1.1.2
- RubyGem 1.2 (phew, finally Gem installation is much faster again
- Bunch of Compatibility and Performance problems
Going forward, JRuby point releases will be on a 3-4 week frequency. And you can always checkout the trunk and build yourself.
Here are few simple steps to get you started:
- Download and unzip the distribution.
- Install Rails and GlassFish gem:
~/testbed/jruby-1.1.3 >./bin/jruby -S gem install rails glassfish –no-ri –no-rdoc
JRuby limited openssl loaded. gem install jruby-openssl for full support.
http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
Successfully installed activesupport-2.1.0
Successfully installed activerecord-2.1.0
Successfully installed actionpack-2.1.0
Successfully installed actionmailer-2.1.0
Successfully installed activeresource-2.1.0
Successfully installed rails-2.1.0
Successfully installed glassfish-0.3.1-universal-java
7 gems installed - Create a new Rails app as:
~/testbed/jruby-1.1.3/samples/rails >../../bin/jruby -S rails helloworld -d mysql
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create db
create doc
. . .
create log/server.log
create log/production.log
create log/development.log
create log/test.log - Run Rails application on GlassFish gem as:
~/testbed/jruby-1.1.3/samples/rails >../../bin/jruby -S glassfish_rails helloworld
Jul 21, 2008 8:32:03 AM com.sun.enterprise.glassfish.bootstrap.ASMain main
INFO: Launching GlassFish on HK2 platform
Jul 21, 2008 8:32:03 AM com.sun.enterprise.glassfish.bootstrap.ASMainHK2 findDerbyClient
INFO: Cannot find javadb client jar file, jdbc driver not available
Jul 21, 2008 8:32:04 AM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
INFO: Listening on port 3000
Jul 21, 2008 8:32:04 AM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL
WARNING: pewebcontainer.all_ssl_protocols_disabled
Jul 21, 2008 8:32:04 AM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL
WARNING: pewebcontainer.all_ssl_ciphers_disabled
Jul 21, 2008 8:32:04 AM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
INFO: Listening on port 3131
Jul 21, 2008 8:32:04 AM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
INFO: Listening on port 3838
Jul 21, 2008 8:32:04 AM com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setContextRoot
INFO: Admin Console Adapter: context root: /admin
Jul 21, 2008 8:32:05 AM com.sun.grizzly.jruby.RailsAdapter startRubyRuntimePool
INFO: Starting Rails instances
Jul 21, 2008 8:32:09 AM
SEVERE: JRuby limited openssl loaded. gem install jruby-openssl for full support.
http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
Jul 21, 2008 8:32:10 AM com.sun.grizzly.jruby.RubyObjectPool$1 run
INFO: JRuby and Rails instance instantiation took : 5623ms
Jul 21, 2008 8:32:10 AM org.glassfish.scripting.rails.RailsDeployer load
INFO: Loading application helloworld at /
Jul 21, 2008 8:32:10 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: Glassfish v3 started in 7046 ms - Create a scaffold as:
~/testbed/jruby-1.1.3/samples/rails/helloworld >../../../bin/jruby script/generate scaffold runner distance:float minutes:integer
JRuby limited openssl loaded. gem install jruby-openssl for full support.
http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
exists app/models/
exists app/controllers/
exists app/helpers/
create app/views/runners
exists app/views/layouts/
exists test/functional/
exists test/unit/
exists public/stylesheets/
create app/views/runners/index.html.erb
create app/views/runners/show.html.erb
create app/views/runners/new.html.erb
create app/views/runners/edit.html.erb
create app/views/layouts/runners.html.erb
create public/stylesheets/scaffold.css
create app/controllers/runners_controller.rb
create test/functional/runners_controller_test.rb
create app/helpers/runners_helper.rb
route map.resources :runners
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/runner.rb
create test/unit/runner_test.rb
create test/fixtures/runners.yml
create db/migrate
create db/migrate/20080721153737_create_runners.rb - Start MySQL database, create and migrate the database:
~/testbed/jruby-1.1.3/samples/rails/helloworld >../../../bin/jruby -S rake db:create
(in /Users/arungupta/testbed/jruby-1.1.3/samples/rails/helloworld)
~
/testbed/jruby-1.1.3/samples/rails/helloworld >../../../bin/jruby -S rake db:migrate
(in /Users/arungupta/testbed/jruby-1.1.3/samples/rails/helloworld)
== 20080721154435 CreateRunners: migrating ====================================
— create_table(:runners)
-> 0.0097s
== 20080721154435 CreateRunners: migrated (0.0104s) ===========================Now “http://localhost:3000/runners” page is shown as:
After adding couple of entries, the page looks like:
Now, let’s try to run the same application on GlassFish v3 stand-alone build.
TOTD #33 explains how to build GlassFish v3 workspace. Alternatively nightly or promoted builds can be downloaded as well.
- Start the v3 server as:
~/testbed/glassfish/v3/snapshot/glassfish >java -DJRUBY_HOME=/Users/arungupta/testbed/jruby-1.1.3 -jar modules/glassfish-10.0-SNAPSHOT.jar
Jul 21, 2008 9:40:41 AM com.sun.enterprise.glassfish.bootstrap.ASMain main
INFO: Launching GlassFish on Apache Felix OSGi platform
Jul 21, 2008 9:40:41 AM com.sun.enterprise.glassfish.bootstrap.ASMainOSGi getSharedRepos
INFO: /Users/arungupta/testbed/glassfish/v3/snapshot/glassfish/domains/domain1/lib does not existWelcome to Felix.
=================. . .
INFO: Started bundle org.glassfish.common.container-common [91]
Jul 21, 2008 9:47:13 AM com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setContextRoot
INFO: Admin Console Adapter: context root: /admin
Jul 21, 2008 9:47:13 AM OSGiModuleImpl loadClass
INFO: Started bundle org.glassfish.deployment.deployment-common [71]
Jul 21, 2008 9:47:13 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: Glassfish v3 started in 1507 ms - Deploy the application as:
~/testbed/jruby-1.1.3/samples/rails >~/testbed/glassfish/v3/snapshot/glassfish/bin/asadmin deploy helloworld Command deploy executed successfully.
and the GlassFish console shows the following output:
Jul 21, 2008 9:47:49 AM OSGiModuleImpl loadClass
INFO: Started bundle org.glassfish.web.war-util [65]
Jul 21, 2008 9:47:49 AM OSGiModuleImpl loadClass
INFO: Started bundle org.glassfish.persistence.jpa-connector [25]
Jul 21, 2008 9:47:49 AM OSGiModuleImpl loadClass
INFO: Started bundle org.glassfish.scripting.gf-jruby-connector [13]
Jul 21, 2008 9:47:49 AM OSGiModuleImpl loadClass
INFO: Started bundle org.glassfish.core.security [22]
Jul 21, 2008 9:47:49 AM OSGiModuleImpl loadClass
INFO: Started bundle org.glassfish.web.gf-web-connector [86]
Jul 21, 2008 9:47:49 AM OSGiModuleImpl loadClass
INFO: Started bundle org.glassfish.connectors.gf-connectors-connector [53]
Jul 21, 2008 9:47:49 AM com.sun.grizzly.jruby.RailsAdapter startRubyRuntimePool
INFO: Starting Rails instances
Jul 21, 2008 9:48:01 AM
SEVERE: JRuby limited openssl loaded. gem install jruby-openssl for full support.
http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
Jul 21, 2008 9:48:02 AM com.sun.grizzly.jruby.RubyObjectPool$1 run
INFO: JRuby and Rails instance instantiation took : 12852ms
Jul 21, 2008 9:48:02 AM org.glassfish.scripting.rails.RailsDeployer load
INFO: Loading application helloworld at /helloworld
Jul 21, 2008 9:48:02 AM com.sun.enterprise.v3.deployment.DeployCommand execute
INFO: Deployment of helloworld done is 13326 msThe deployed application at “http://localhost:8080/helloworld/runners” looks like:
Rails powered by the GlassFish Application Server explain in detail about the several benefits of using GlassFish for Rails development and deployment. Rails/GlassFish Deployment Stories gives a good idea of how to structure your own application.
Are you using GlassFish for development or deployment of Rails ? Drop a comment on this blog.
Technorati: rubyonrails jruby ruby glassfish v3 gem
Related posts:- JRuby 1.1.2 released – Getting Started with v3 Gem
- JRuby 1.0.2 released – Improved Windows experience and Rails 1.2.5 support
- TOTD #24: Getting Started with Rails 2.0.x in JRuby 1.0.3 and JRuby 1.1RC1
- Getting Started with Edge Rails (2.2) using JRuby and GlassFish
- JRuby 1.1 released – ready for production!
Hi Arun,
Your Glassfish gem is very cool, especially the ease of use. But I’m still missing a few features to use it for production usage:
1) I think JNDI JDBC connection pooling isn’t working with the gem, see my bug report here:
http://rubyforge.org/tracker/index.php?func=detail&aid=21115&group_id=5450&atid=21080
2) I doubt Rails static page caching works properly. Indeed, even if you stored to cached files at the right place and serve them as regular static content, you would probably encounter that bug I just patched with Warble:
http://jira.codehaus.org/browse/JRUBY-2832
So that’s why I’m sticking with Glassfish v2 so far, but it would be great to make that gem just as good to use it for production as well. So I would appreciate to know more about those two issues.
Regards,
Raphaël Valyi.
Comment by Raphaël Valyi — July 21, 2008 @ 12:04 pm
[Trackback] Here is a (year old) community contributed video showing how to deploy a Ruby-on-Rails application on GlassFish v2 application server: The presenter is not speaking and typing really fast, I wish there was a slower playback available Anyway,…
Comment by Arun Gupta's Blog — August 6, 2008 @ 2:58 pm
[Trackback] Charlie describes, in 4 easy steps, how to deploy any Rails application on GlassFish: The main steps are: Step 1: The App Server Step 2: Package your App Step 3: Deploy your application Step 4: Tweaking (Optional) And it should…
Comment by Arun Gupta's Blog — August 27, 2008 @ 4:08 pm
[Trackback] Last day of Rails Conf Europe 2008 (Day 1 & Day 2), and it’s finally over! David Black’s opening session talked about Ruby and Rails Symposium: Versions, Implementations, and the Future. Here is a brief summary of MRI Ruby…
Comment by Arun Gupta's Blog — September 5, 2008 @ 10:19 pm
I am using JRuby 1.1.6, Rails 2.2.2 and the v3 prelude server. If I run my application using the gem, as in -
glassfish_rails myapp
then Rails comes up correctly in the threadsafe version (I have config.threadsafe! in my configuration)
When I deploy the same application using asadmin deploy, the application starts, but it looks like Rails does not come up in the threadsafe mode, causing the instance to hang (my application relies on threadsafe mode and has long running requests). Any ideas on how to make Rails come up in threadsafe mode while running apps natively?
Comment by Girish Kulkarni — December 26, 2008 @ 10:21 am
Girish, have you tried the instructions at:
http://blogs.sun.com/arungupta/entry/getting_started_with_edge_rails
?
Comment by Arun Gupta — January 5, 2009 @ 3:28 pm
Arun,
Yes, I followed those instructions. I am using more recent versions of JRuby (1.1.6) and the Prelude server than mentioned at the above link, but I don’t think it should matter.
Rails does come up in the thread safe mode when started as ‘glassfish_rails myapp’, as indicated by the application behavior (it works as expected) as well as the following message -
INFO: config.threadsafe sighted! All hands prepare for multithread mode!
On the other hand, if I start the glassfish server after using asadmin to deploy the application, it does not work as expected. Are there any settings apart from what I have in the environments file? Any traces to see what is happening under the covers?
Thanks,
- Girish
Comment by Girish Kulkarni — January 5, 2009 @ 5:28 pm
Girish, This is reported as bug at:
https://glassfish.dev.java.net/issues/show_bug.cgi?id=6977
Please monitor the bug for further updates on this issue.
Comment by Arun Gupta — January 8, 2009 @ 4:11 pm
[Trackback] Bookmarked your site as jruby at JabberTags!
Comment by JabberTags - Find New Sites and Explore the Internet — March 10, 2009 @ 12:19 am