TOTD # 71: JRuby and GlassFish Integration Test #2: JRuby 1.2.0 RC1 + Rails 2.2.x + GlassFish v3 Prelude
Posted by arungupta on March 5, 2009 at 10:07 AM EST
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.
- 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]. - 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.
- Deploy the application as:
~/tools/jruby-1.2.0RC1/samples/rails >~/tools/glassfish/v3/glassfishv3-prelude/bin/asadmin deploy runner
Command deploy executed successfully.
- 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. - Lets try with the JRuby trunk.
- 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 - 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... - 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. - 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.
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
Related Topics >>
Blog Links >>
- Login or register to post comments
- Printer-friendly version
- arungupta's blog
- 693 reads





