Re: Jruby/Rails 2/Tomcat 5.5
I've been seeing similar kinds of problems with goldspike swallowing rails initialization
exceptions and have traced it down to line 85 of RailsServlet.java:
runtime.defineReadonlyVariable("$java_servlet_response", JavaEmbedUtils.javaToRuby(runtime, response));
For some reason, when rails fails to initialize, trying to wrap the response blows up.
I have been working around this by catching, reporting and otherwise ignoring the exceptions
thrown by the line above separately. If you apply the patch below, you will get coherent
ruby level error reporting when your rails application fails to initialize:
Index: src/main/java/org/jruby/webapp/RailsServlet.java
===================================================================
--- src/main/java/org/jruby/webapp/RailsServlet.java (revision 908)
+++ src/main/java/org/jruby/webapp/RailsServlet.java (working copy)
@@ -82,7 +82,11 @@
// variables to expose
runtime.defineReadonlyVariable("$stdin", stdin);
runtime.defineReadonlyVariable("$java_servlet_request", JavaEmbedUtils.javaToRuby(runtime, request));
- runtime.defineReadonlyVariable("$java_servlet_response", JavaEmbedUtils.javaToRuby(runtime, response));
+ try {
+ runtime.defineReadonlyVariable("$java_servlet_response", JavaEmbedUtils.javaToRuby(runtime, response));
+ } catch (Exception e) {
+ log("Warning: Failed to set Ruby variable $java_servlet_response" + e.getMessage());
+ }
// $servlet_context is added when the runtime is created
// setup the default session
Russ Olsen