dev@grizzly.java.net

Patch to fix the Dynamic request processing for a ROR application deployed at root contet

From: Pramod Gopinath <Pramod.Gopinath_at_Sun.COM>
Date: Wed, 13 Feb 2008 10:26:18 -0800

Hi
  Sending in a patch to fix an issue that I ran into when trying to
deploy a ROR application inside the GlassFish V3 server.
The issue was that if I had the application deployed on the root context
the static files were working correctly, but the dynamic requests -
controller/action were not working correctly. This had to do with the
"ActionController::<Abstract/Cgi>Request." settings that were defined in
the dispatch.rb.
These settings are only required if the application is not at the root
context.

Have checked this with JRuby 1.0.3, JRuby 1.1RC and trunk bits using
mephisto application.

Thanks
Pramod Gopinath


 svn diff resources/dispatch.rb
java/com/sun/grizzly/jruby/RailsAdapter.java
Index: resources/dispatch.rb
===================================================================
--- resources/dispatch.rb (revision 798)
+++ resources/dispatch.rb (working copy)
@@ -55,8 +55,11 @@
   ENV['HTTP_' + name.upcase.tr('-','_')] = value
 end
 
-ActionController::AbstractRequest.relative_url_root = $root
-ActionController::CgiRequest.relative_url_root = $root
+if !$root.nil?
+ ActionController::AbstractRequest.relative_url_root = $root
+ ActionController::CgiRequest.relative_url_root = $root
+end
+
 require "dispatcher"
 
 Dispatcher.dispatch
Index: java/com/sun/grizzly/jruby/RailsAdapter.java
===================================================================
--- java/com/sun/grizzly/jruby/RailsAdapter.java (revision 798)
+++ java/com/sun/grizzly/jruby/RailsAdapter.java (working copy)
@@ -106,8 +106,8 @@
             runtime.defineReadonlyVariable("$stdin", iObj);
             runtime.defineReadonlyVariable("$stdout", oObj);
             runtime.defineReadonlyVariable("$logger", loggerObj);
-
- if (contextRoot!=null) {
+
+ if (contextRoot!=null && !contextRoot.equals("/")) {
                 runtime.defineReadonlyVariable("$root",
                         JavaEmbedUtils.javaToRuby(runtime, contextRoot));
             }
pramod-gopinaths-computer:~/work_related/grizzly_code/grizzly/trunk/modules