TOTD # 71: JRuby and GlassFish Integration Test #2: JRuby 1.2.0 RC1 + Rails 2.2.x + GlassFish v3 Prelude


TOTD #70 shows the first integration integration tests that I typically run to ensure that the latest JRuby and GlassFish versions work nicely with each other.  The second test (explained in this blog) ensures that the same application can be deployed using GlassFish v3 Prelude.

GlassFish v3 Prelude allows Rails applications to be deployed natively, i.e. without any packaging.

Lets begin integration test #2.
  1. Download and unzip GlassFish v3 Prelude. Fire up GlassFish v3 Prelude as:

    ~/tools/glassfish/v3/glassfishv3-prelude/glassfish >./bin/asadmin start-domain
    Name of the domain started: [domain1] and
    its location: [/Users/arungupta/tools/glassfish/v3/glassfishv3-prelude/glassfish/domains/domain1].
    Admin port for the domain: [4848].
  2. Add JRUBY_HOME as "jvm-option" using the following command:

    ~/tools/glassfish/v3/glassfishv3-prelude/glassfish >./bin/asadmin create-jvm-options -DJRUBY_HOME="/Users/arungupta/tools/jruby-1.2.0RC1"
    created 1 option(s)

    Command create-jvm-options executed successfully.

    This tells the GlassFish runtime to pick JRuby and related libraries from the directory specified in JRUBY_HOME.
  3. Deploy the application as:

    ~/tools/jruby-1.2.0RC1/samples/rails >~/tools/glassfish/v3/glassfishv3-prelude/bin/asadmin deploy runner

    Command deploy executed successfully.

  4. The application should now be accessible on "http://localhost:8080/runner/runners". But instead the logs (located in "domains/domain1/logs/server.log) shows the following exception:

    Caused by: java.lang.NumberFormatException: For input string: "0RC1"
            at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
            at java.lang.Integer.parseInt(Integer.java:456)
            at java.lang.Integer.parseInt(Integer.java:497)
            at com.sun.grizzly.jruby.RailsAdapter$JRubyVersion.<init>(RailsAdapter.java:137)
            at com.sun.grizzly.jruby.RailsAdapter$JRubyVersion.<init>(RailsAdapter.java:131)
            at com.sun.grizzly.jruby.RailsAdapter.<init>(RailsAdapter.java:110)
            at com.sun.grizzly.jruby.RubyRuntime.<init>(RubyRuntime.java:48)
            ... 30 more

    This is filed as issue #7235 in GlassFish Issue Tracker.
  5. Lets try with the JRuby trunk.
    1. Check out JRuby trunk and build the workspace as shown below

      ~/workspaces >svn co http://svn.codehaus.org/jruby/trunk/jruby/
      A    jruby/bench
      A    jruby/bench/bench_tak.rb
      A    jruby/bench/bench_struct.rb

      . . .

      A    jruby/.settings/org.eclipse.jdt.core.prefs
      A    jruby/.settings/org.eclipse.jdt.ui.prefs
       U   jruby
      Checked out revision 9347.
      ~/workspaces >cd jruby/
      ~/workspaces/jruby >ant
      Buildfile: build.xml

      init:

      jar:

      . . .

      _update_scm_revision_:
            [jar] Building jar: /Users/arungupta/workspaces/jruby/lib/jruby.jar
            [jar] Warning: selected jar files include a META-INF/INDEX.LIST which will be replaced by a newly generated one.

      BUILD SUCCESSFUL
      Total time: 1 minute 21 seconds
    2. Install Rails

      ~/workspaces/jruby >./bin/jruby gem install rails
      JRuby limited openssl loaded. gem install jruby-openssl for full support.
      http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
      Successfully installed rake-0.8.4
      Successfully installed activesupport-2.2.2
      Successfully installed activerecord-2.2.2
      Successfully installed actionpack-2.2.2
      Successfully installed actionmailer-2.2.2
      Successfully installed activeresource-2.2.2
      Successfully installed rails-2.2.2
      7 gems installed
      Installing ri documentation for rake-0.8.4...
      Installing ri documentation for activesupport-2.2.2...
      Installing ri documentation for activerecord-2.2.2...
      Installing ri documentation for actionpack-2.2.2...
      Installing ri documentation for actionmailer-2.2.2...
      Installing ri documentation for activeresource-2.2.2...
      Installing RDoc documentation for rake-0.8.4...
      Installing RDoc documentation for activesupport-2.2.2...
      Installing RDoc documentation for activerecord-2.2.2...
      Installing RDoc documentation for actionpack-2.2.2...
      Installing RDoc documentation for actionmailer-2.2.2...
      Installing RDoc documentation for activeresource-2.2.2...
  6. Delete the previously added jvm-option as

    ~/tools/glassfish/v3/glassfishv3-prelude/glassfish >./bin/asadmin delete-jvm-options -DJRUBY_HOME="/Users/arungupta/tools/jruby-1.2.0RC1"
    deleted 1 option(s)

    Command delete-jvm-options executed successfully.

    and add a new jvm-option pointing to the the new JRUBY_HOME as

    ~/tools/glassfish/v3/glassfishv3-prelude/glassfish >./bin/asadmin create-jvm-options -DJRUBY_HOME="/Users/arungupta/workspaces/jruby"
    created 1 option(s)

    Command create-jvm-options executed successfully.
  7. Deploy the application as:

    ~/tools/jruby-1.2.0RC1/samples/rails >~/tools/glassfish/v3/glassfishv3-prelude/bin/asadmin deploy --force=true runner

    Command deploy executed successfully.

    The "NumberFormatException" as seen above is shown again in this case.

    If the application is deployed correctly then "http://localhost:8080/runner/runners" will show the scaffold page. The final JRuby 1.2 release will not have any text letters in the version and so you'll be able to deploy a Rails application using JRuby 1.2 (final release) on GlassFish v3 Prelude.
But for now our test #2 has failed.

Subsequent blogs will show the remainder of tests. The current set of tests are available using the tags rubyonrails+glassfish+integrationtest.

Please leave suggestions on other TOTD (Tip Of The Day) that you'd like to see. A complete archive of all tips is available here.

Technorati: totd rubyonrails glassfish v3 jruby gem integrationtest
Comments:

[Trackback] TOTD #70&nbsp;and #71 shows the first two integration tests that I typically run to ensure that the latest JRuby and GlassFish versions work nicely with each other. &nbsp;#70 showed how to create a trivial Rails application and run it...

Posted by Arun Gupta's Blog on March 08, 2009 at 11:39 PM PDT #

[Trackback] TOTD #70, #71, #72 shows the first three integration tests that I typically run to ensure that the latest JRuby and GlassFish versions work nicely with each other. &nbsp;#70 showed how to create a trivial Rails application and run...

Posted by Arun Gupta's Blog on March 11, 2009 at 06:22 AM PDT #

[Trackback] TOTD #70, #71, #72, #73 shows four integration tests that can ensure that the latest JRuby and GlassFish versions work nicely with each other. #70 showed how to create a trivial Rails application and run it using GlassFish Gem.&nbsp;#71...

Posted by Arun Gupta's Blog on March 16, 2009 at 04:49 AM PDT #

[Trackback] TOTD #70, #71, #72, #73 shows four integration tests that can ensure that the latest JRuby and GlassFish versions work nicely with each other. #70 showed how to create a trivial Rails application and run it using GlassFish Gem.&nbsp;#71...

Posted by Arun Gupta's Blog on March 16, 2009 at 04:53 AM PDT #

[Trackback] This is a follow up post from David's keynote. Attended Women in Rails panel discussion. The panel, Sarah Mei, Lori Olson, and Desi McAdam (from L to R), had a very interesting discussion around the genuine problems and possible solutions...

Posted by Arun Gupta's Blog on May 05, 2009 at 10:40 PM PDT #

Post a Comment:
Comments are closed for this entry.
About

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.


Java EE 7 Samples

Stay Connected

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today