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.
- 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]. - 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.
- Deploy the application as:
~/tools/jruby-1.2.0RC1/samples/rails >~/tools/glassfish/v3/b39/glassfishv3/bin/asadmin deploy runner Command deploy executed successfully.
- 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’
:1This resulted in filing issue #7266.
- 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. - 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
Related posts:- TOTD #71: JRuby and GlassFish Integration Test #2: JRuby 1.2.0 RC1 + Rails 2.2.x + GlassFish v3 Prelude
- TOTD #73: JRuby and GlassFish Integration Test #4: JRuby 1.2.0 RC2 + Rails 2.2.x + GlassFish v2 + Warbler
- TOTD #70: JRuby and GlassFish Integration Test# 1: JRuby 1.2.0 RC1 + Rails 2.2.x + GlassFish Gem
- TOTD #74: JRuby and GlassFish Integration Test #5: JRuby 1.2.0 RC2 + Rails 2.x.x + GlassFish + Redmine
- TOTD# 36: Writing First Test for a Rails Application
[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. #70 showed how to create a trivial Rails application and run…
Comment by Arun Gupta's Blog — March 11, 2009 @ 1:22 pm
[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. #71…
Comment by Arun Gupta's Blog — March 16, 2009 @ 11:49 am
[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. #71…
Comment by Arun Gupta's Blog — March 16, 2009 @ 11:53 am
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)
Comment by Benny Iskandar — April 13, 2009 @ 11:37 pm
Benny,
Did you follow the instructions as explained at: http://blogs.sun.com/arungupta/entry/totd_71_jruby_and_glassfish ?
Comment by Arun Gupta — April 16, 2009 @ 1:43 pm
[...] TOTD #72: Deploying Rails application on GlassFish v3 [...]
Pingback by TOTD #110: JRuby on Rails application using Oracle on GlassFish « Miles to go … — October 6, 2009 @ 3:03 pm