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


TOTD #70 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.  #70 showed how to create a trivial Rails application and run it using GlassFish Gem. #71 showed how the same application can be deployed on GlassFish v3 Prelude.

The third test (explained in this blog) ensures that the same application can be easily deployed using 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. Test #1 passed, Test #2 gives the following error:

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:



So 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 GlassFish v3, b39 is the latest at time of this writing. Fire up GlassFish v3 as:

    ~/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:

    ~/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:

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

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

    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 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:

    ~/tools/jruby-1.2.0RC1/samples/rails >~/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 issue #7270 and 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:

    ~/tools/jruby-1.2.0RC2/samples/rails >~/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:


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 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, #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 #

Hi Arun Gupta,

I've a problem with deployment jruby rails inside the glassfish :

C:\\work\\jrubyonrails>C:\\program\\glassfishv3-prelude\\bin\\asadmin.bat deploy hello
remote failure: Module type not recognized

Command deploy failed.

C:\\work\\jrubyonrails>_

When i saw at the server.log files said that :
[#|2009-04-14T14:29:23.875+0800|FINE|glassfish|javax.enterprise.system.util|_ThreadID=17;_ThreadName=Thread-3;ClassName=null;MethodName=null;C:\\program\\glassfishv3-prelude\\glassfish\\domains\\beepcast\\applications\\hello;|UTIL6049: Attempt to delete C:\\program\\glassfishv3-prelude\\glassfish\\domains\\beepcast\\applications\\hello failed; the file is reported as non-existent|#]

[#|2009-04-14T14:29:23.890+0800|FINE|glassfish|javax.enterprise.system.util|_ThreadID=17;_ThreadName=Thread-3;ClassName=null;MethodName=null;|No local string for deploy.unknownmoduletpe|#]

[#|2009-04-14T14:29:23.890+0800|SEVERE|glassfish|javax.enterprise.system.core|_ThreadID=17;_ThreadName=Thread-3;|Module type not recognized|#]

Any idea why it can happen for "Module type not recognized" ? I've used the latest version of :
- jruby 1.1.5 (ruby 1.8.6 patchlevel 114) (2008-11-03 rev 7996) [x86-java]
- GlassFish v3 Prelude (build b28c)

Posted by Benny Iskandar on April 13, 2009 at 04:37 PM PDT #

Benny,

Did you follow the instructions as explained at: http://blogs.sun.com/arungupta/entry/totd_71_jruby_and_glassfish ?

Posted by Arun Gupta on April 16, 2009 at 06:43 AM PDT #

Hi Arun,

Everytime am downloading glassfish am getting this type of error shown below can you please help me in resolving this error because am trying this from last 2 weeks i appreciate your help if you can able to :

reating domain
_______________
Executing command :C:\glassfish3\glassfish\bin\asadmin.bat --user admin --passwordfile - create-domain --savelogin --checkports=false --adminport 4848 --instanceport 8080 --domainproperties=jms.port=7676:domain.jmxPort=8686:orb.listener.port=3700:http.ssl.port=8181:orb.ssl.port=3820:orb.mutualauth.port=3920 domain1
C:\glassfish3\glassfish\bin\asadmin.bat --user admin --passwordfile - create-domain --savelogin --checkports=false --adminport 4848 --instanceport 8080 --domainproperties=jms.port=7676:domain.jmxPort=8686:orb.listener.port=3700:http.ssl.port=8181:orb.ssl.port=3820:orb.mutualauth.port=3920 domain1 The system cannot find the path specified.

Posted by guest on April 08, 2013 at 02:46 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