Skip to main content

JRuby 1.0.2 released - Improved Windows experience and Rails 1.2.5 support

Posted by arungupta on November 9, 2007 at 7:16 AM PST


JRuby 1.0.2
was released
last week.

A total of 99 issues were fixed but I'm particularly excited
about JRUBY-1347,
JRUBY-1350,
JRUBY-1401 and
JRUBY-1410. These are
some issues that I faced (1347
here
,

1350 here
,
1401 here,
1410
here
) on my primary development machine - Windows.

Here is the status report:

  • On Windows only, the latest Rails gem (1.2.5) is now working
    with stable release of JRuby (1.0.2 as of today).

  • On Windows only,

    GlassFish v3 gem
    does not work with JRuby 1.0.2 but works with the JRuby
    trunk (JRUBY-1549).
    The gem works correctly on Solaris and Mac.

  • JRuby 1.0.2 bundles will be available on

    GlassFish Update Center
    soon.

Now the details.

Here is the command sequence for creating and hosting a trivial
Hello World on WEBrick:

  1. Install Rails



    C:\testbed\ruby\jruby-1.0.2>bin\jruby -S gem install rails 
    --include-dependencies --no-ri --no-rdoc<br>
    Bulk updating Gem source index for: http://gems.rubyforge.org<br>
    Successfully installed rails-1.2.5<br>
    Successfully installed activesupport-1.4.4<br>
    Successfully installed activerecord-1.15.5<br>
    Successfully installed actionpack-1.13.5<br>
    Successfully installed actionmailer-1.3.5<br>
    Successfully installed actionwebservice-1.2.5
  2. Create a template application



    C:\workarea\samples\rails&gt;\testbed\ruby\jruby-1.0.2\bin\jruby -S rails 
    hello<br>
    &nbsp;create<br>
    create app/controllers<br>
    create app/helpers<br>
    create app/models<br>
    create app/views/layouts<br>
    create config/environments<br>
    create components<br>
    create db<br>
    create doc<br>
    create lib<br>
    create lib/tasks<br>
    create log<br>
    create public/images<br>
    create public/javascripts<br>
    create public/stylesheets<br>
    create script/performance<br>
    create script/process<br>
    create test/fixtures<br>
    create test/functional<br>
    create test/integration<br>
    create test/mocks/development<br>
    create test/mocks/test<br>
    create test/unit<br>
    create vendor<br>
    create vendor/plugins<br>
    create tmp/sessions<br>
    create tmp/sockets<br>
    create tmp/cache<br>
    create tmp/pids<br>
    create Rakefile<br>
    create README<br>
    create app/controllers/application.rb<br>
    create app/helpers/application_helper.rb<br>
    create test/test_helper.rb<br>
    create config/database.yml<br>
    create config/routes.rb<br>
    create public/.htaccess<br>
    create config/boot.rb<br>
    create config/environment.rb<br>
    create config/environments/production.rb<br>
    create config/environments/development.rb<br>
    create config/environments/test.rb<br>
    create script/about<br>
    create script/breakpointer<br>
    create script/console<br>
    create script/destroy<br>
    create script/generate<br>
    create script/performance/benchmarker<br>
    create script/performance/profiler<br>
    create script/process/reaper<br>
    create script/process/spawner<br>
    create script/process/inspector<br>
    create script/runner<br>
    create script/server<br>
    create script/plugin<br>
    create public/dispatch.rb<br>
    create public/dispatch.cgi<br>
    create public/dispatch.fcgi<br>
    create public/404.html<br>
    create public/500.html<br>
    create public/index.html<br>
    create public/favicon.ico<br>
    create public/robots.txt<br>
    create public/images/rails.png<br>
    create public/javascripts/prototype.js<br>
    create public/javascripts/effects.js<br>
    create public/javascripts/dragdrop.js<br>
    create public/javascripts/controls.js<br>
    create public/javascripts/application.js<br>
    create doc/README_FOR_APP<br>
    create log/server.log<br>
    create log/production.log<br>
    create log/development.log<br>
    create log/test.log
  3. Add a controller



    C:\workarea\samples\rails&gt;cd hello<br>
    <br>
    C:\workarea\samples\rails\hello&gt;\testbed\ruby\jruby-1.0.2\bin\jruby
    script\generate controller say hello<br>
    exists app/controllers/<br>
    exists app/helpers/<br>
    create app/views/say<br>
    exists test/functional/<br>
    create app/controllers/say_controller.rb<br>
    create test/functional/say_controller_test.rb<br>
    create app/helpers/say_helper.rb<br>
    create app/views/say/hello.rhtml
  4. Edit Controller



    C:\workarea\samples\rails\hello>vim app\controllers\say_controller.rb

    Add  @hello_string = &quot;Hello from 1.0.2&quot; in
    hello helper. The updated file looks like:



    class SayController &lt; ApplicationController<br>
    <br>
    &nbsp; def hello<br>
    &nbsp;&nbsp;&nbsp; @hello_string = &quot;Hello from 1.0.2&quot;<br>
    &nbsp; end<br>
    end
  5. Edit View

    C:\workarea\samples\rails\hello>vim app\views\say\hello.rhtml

    and add &lt;%= @hello_string %&gt; as the last line.
    The updated file looks like:



    &lt;h1&gt;Say#hello&lt;/h1&gt;<br>
    &lt;p&gt;Find me in app/views/say/hello.rhtml&lt;/p&gt;<br>
    &lt;%= @hello_string %&gt;
  6. Start WEBrick and view the page

    	http://localhost:3000/say/hello
    in a browser window:



    C:\workarea\samples\rails\hello&gt;\testbed\ruby\jruby-1.0.2\bin\jruby 
    script\server<br>
    =&gt; Booting WEBrick...<br>
    =&gt; Rails application started on http://0.0.0.0:3000<br>
    =&gt; Ctrl-C to shutdown server; call with --help for options<br>
    [2007-11-07 17:22:01] INFO WEBrick 1.3.1<br>
    [2007-11-07 17:22:01] INFO ruby 1.8.5 (2007-11-01) [java]<br>
    [2007-11-07 17:22:01] INFO WEBrick::HTTPServer#start: pid=11245030 port=3000<br>
    127.0.0.1 - - [07/Nov/2007:17:22:38 PST] &quot;GET /say/hello HTTP/1.1&quot; 200 81<br>
    - -&gt; /say/hello

The

GlassFish v3 Gem
does not work with JRuby 1.0.2 (JRUBY-1549)
on Windows. It works very well on Solaris and Mac. For Windows, you need to use
the JRuby trunk (checkout
and build
):

After you've built the JRuby trunk, you can create a similar new
application and run it on GlassFish v3 gem as:


  1. Download
    and

    Install
    the gem



    C:\workspaces\jruby-trunk&gt;bin\jruby -S gem install 
    glassfish-gem-10.0-SNAPSHOT.gem<br>
    Successfully installed GlassFish, version 10.0.0
  2. Start GlassFish v3 and view the page

    	http://localhost:8080/hello/say/hello
    :



    C:\workarea\samples\rails&gt;\workspaces\jruby-trunk\bin\jruby -S 
    glassfish_rails hello<br>
    Nov 8, 2007 2:39:07 PM com.sun.enterprise.v3.services.impl.GrizzlyAdapter
    postConstruct<br>
    INFO: Listening on port 8080<br>
    Nov 8, 2007 2:39:08 PM com.sun.enterprise.v3.services.impl.DeploymentService
    postConstruct<br>
    INFO: Supported containers : php,phobos,jruby,web<br>
    Nov 8, 2007 2:39:08 PM com.sun.grizzly.standalone.StaticResourcesAdapter
    &lt;init&gt;<br>
    INFO: New Servicing page from: C:\workarea\samples\rails\hello\public<br>
    Nov 8, 2007 2:39:15 PM com.sun.enterprise.v3.server.AppServerStartup run<br>
    INFO: Glassfish v3 started in 7588 ms<br>
    Nov 8, 2007 2:39:27 PM sun.reflect.NativeMethodAccessorImpl invoke0<br>
    INFO:<br>
    <br>
    Processing SayController#hello (for 127.0.0.1 at 2007-11-08 14:39:27) [GET]<br>
    <br>
    Nov 8, 2007 2:39:27 PM sun.reflect.NativeMethodAccessorImpl invoke0<br>
    INFO: Session ID: 46e3279ab4f2d776b4d76010cc7b38af<br>
    <br>
    Nov 8, 2007 2:39:27 PM sun.reflect.NativeMethodAccessorImpl invoke0<br>
    INFO: Parameters: {&quot;action&quot;=&gt;&quot;hello&quot;, &quot;controller&quot;=&gt;&quot;say&quot;}<br>
    <br>
    Nov 8, 2007 2:39:27 PM sun.reflect.NativeMethodAccessorImpl invoke0<br>
    INFO: Rendering say/hello<br>
    <br>
    Nov 8, 2007 2:39:27 PM sun.reflect.NativeMethodAccessorImpl invoke0<br>
    INFO: Completed in 0.01100 (90 reqs/sec) | Rendering: 0.00900 (81%) | 200 OK
    [http://localhost/hello/say/hello]

A comprehensive list of JRuby on GlassFish documentation is
available here.

Technorati:
jrubyonglassfish
jruby
glassfish
windows
rubyonrails
v3

Related Topics >>