Skip to main content

TOTD # 72: JRuby and GlassFish Integration Test #3: JRuby 1.2.0 RC2 + Rails 2.2.x + GlassFish v3

Posted by arungupta on March 9, 2009 at 7:38 AM PDT



href="http://blogs.sun.com/arungupta/entry/totd_70_jruby_and_glassfish">TOTD
#70 and href="http://blogs.sun.com/arungupta/entry/totd_71_jruby_and_glassfish">#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.
  href="http://blogs.sun.com/arungupta/entry/totd_70_jruby_and_glassfish">#70
showed how to create a trivial Rails application and run it using href="http://rubyforge.org/projects/glassfishgem/">GlassFish
Gem. href="http://blogs.sun.com/arungupta/entry/totd_71_jruby_and_glassfish">#71
showed how the same application can be deployed on href="https://glassfish.dev.java.net/downloads/v3-prelude.html">GlassFish
v3 Prelude.



The third test (explained in this blog) ensures that the
same
application can be easily deployed using href="http://download.java.net/glassfish/v3/promoted/">GlassFish
v3. GlassFish v3 will be available later this year with full
support for Java EE 6.



JRuby 1.2.0 RC2 is now released.  href="http://blogs.sun.com/arungupta/entry/totd_70_jruby_and_glassfish">Test
#1 passed,  href="http://blogs.sun.com/arungupta/entry/totd_71_jruby_and_glassfish">Test
#2 gives the following error:


style="text-align: left; background-color: rgb(204, 204, 255); width: 100%;"
cellpadding="2" cellspacing="2">
Caused by: java.lang.NumberFormatException: For input
string: "0RC2"

       
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)

       
... 22 more



However running the same application using JRuby trunk (rev 9372) shows
the following output:



alt=""
src="http://blogs.sun.com/arungupta/resource/ror/jruby12-postrc2-trunk-rail222-v3-prelude.png">



So href="http://blogs.sun.com/arungupta/entry/totd_71_jruby_and_glassfish">test
#2 passes with trunk but fails with RC2 bits. The final
release of 1.2 will not have any characters and so this test will pass
with the final JRuby 1.2 bits.



Now, lets begin the integration test #3.

  1. Download and unzip the latest href="http://download.java.net/glassfish/v3/promoted/">GlassFish
    v3, href="http://download.java.net/glassfish/v3/promoted/glassfish-v3-ea-b39.zip">b39
    is the latest at time of this writing. Fire up GlassFish v3 as:


    style="text-align: left; background-color: rgb(204, 204, 255); width: 100%;"
    cellpadding="2" cellspacing="2">
    ~/tools/glassfish/v3/b39/glassfishv3/glassfish
    >./bin/asadmin
    start-domain


    Name of the domain started: [domain1] and

    its location:
    [/Users/arungupta/tools/glassfish/v3/b39/glassfishv3/glassfish/domains/domain1].

    Admin port for the domain: [4848].
  2. Add JRUBY_HOME as "jvm-option" using the following command:


    style="text-align: left; background-color: rgb(204, 204, 255); width: 100%;"
    cellpadding="2" cellspacing="2">
    ~/tools/glassfish/v3/b39/glassfishv3/glassfish
    >./bin/asadmin
    create-jvm-options -DJRUBY_HOME="/Users/arungupta/tools/jruby-1.2.0RC2"


    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:


    style="text-align: left; background-color: rgb(204, 204, 255); width: 100%;"
    cellpadding="2" cellspacing="2">
    ~/tools/jruby-1.2.0RC1/samples/rails > style="font-weight: bold;">~/tools/glassfish/v3/b39/glassfishv3/bin/asadmin
    deploy runner



    Command deploy executed successfully.
  4. Accessing "http://localhost:8080/runner/runners" gives the
    error:


    style="text-align: left; background-color: rgb(204, 204, 255); width: 100%;"
    cellpadding="2" cellspacing="2">
    ActionController::RoutingError (No route matches
    "s" with {:method=>:get}):

       
    /Users/arungupta/tools/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/routing/recognition_optimisation.rb:66:in
    `recognize_path'

       
    /Users/arungupta/tools/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/routing/route_set.rb:386:in
    `recognize'

       
    /Users/arungupta/tools/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:182:in
    `handle_request'

       
    /Users/arungupta/tools/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:110:in
    `dispatch_unlocked'

       
    /Users/arungupta/tools/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:123:in
    `dispatch'

       
    /Users/arungupta/tools/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in
    `dispatch'

       
    /Users/arungupta/tools/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:132:in
    `dispatch_cgi'

       
    /Users/arungupta/tools/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:39:in
    `dispatch'

       
    file:/Users/arungupta/tools/glassfish/v3/b39/glassfishv3/glassfish/modules/grizzly-jruby.jar!/rack/adapter/rails.rb:82:in
    `serve_rails'

       
    file:/Users/arungupta/tools/glassfish/v3/b39/glassfishv3/glassfish/modules/grizzly-jruby.jar!/rack/adapter/rails.rb:109:in
    `call'

       
    file:/Users/arungupta/tools/glassfish/v3/b39/glassfishv3/glassfish/modules/grizzly-jruby.jar!/jruby/rack/rails.rb:81:in
    `call'

       
    file:/Users/arungupta/tools/glassfish/v3/b39/glassfishv3/glassfish/modules/grizzly-jruby.jar!/rack/handler/grizzly.rb:55:in
    `call'

        :1



    This resulted in filing href="https://glassfish.dev.java.net/issues/show_bug.cgi?id=7266">issue
    #7266.

  5. GlassFish v3 allows an application to be
    deployed/redeployed on a different context root by specifying
    "--contextroot" switch. Lets try to deploy the app using a different
    context root as shown below:


    style="text-align: left; background-color: rgb(204, 204, 255); width: 100%;"
    cellpadding="2" cellspacing="2">
    ~/tools/jruby-1.2.0RC1/samples/rails > style="font-weight: bold;">~/tools/glassfish/v3/b39/glassfishv3/bin/asadmin
    deploy --contextroot runlog --force=true runner



    Command deploy executed successfully.



    Even though the application is deployed successful, but now
    "http://localhost:8080/runlog/runners" and
    "http://localhost:8080/runner/runners" give a 404. This resulted in
    filing href="https://glassfish.dev.java.net/issues/show_bug.cgi?id=7270">issue
    #7270 and href="https://glassfish.dev.java.net/issues/show_bug.cgi?id=7271">issue#
    7271. The context root strippping does not happen correctly
    if a Rails application is deployed. But the good news is that a fix is
    already in progress. A workaround is to create exactly the same
    application with a different name.

  6. Recreate the application using a name different from the
    controller. Lets use the name "runlog" and redeploy the application as:


    style="text-align: left; background-color: rgb(204, 204, 255); width: 100%;"
    cellpadding="2" cellspacing="2">
    ~/tools/jruby-1.2.0RC2/samples/rails > style="font-weight: bold;">~/tools/glassfish/v3/b39/glassfishv3/bin/asadmin
    deploy runlog



    Command deploy executed successfully.



    After adding few entries the page at
    "http://localhost:8080/runlog/runners" looks like:



    alt=""
    src="http://blogs.sun.com/arungupta/resource/ror/jruby12rc2-rail222-v3.png">



So test #3 fails if the Application and Controller name are same but
passes if they are different. Our original application did not run so
test #3 failed.



Later blogs will show the remainder of tests. The current set of tests
are available using the tags href="http://blogs.sun.com/arungupta/tags/jruby+glassfish+integrationtest">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 href="http://blogs.sun.com/arungupta/tags/totd">here.




Technorati: totd
rubyonrails
glassfish
v3 href="http://technorati.com/tag/jruby">jruby href="http://technorati.com/tags/gem">gem
integrationtest

Related Topics >>