« Return to Thread: Jruby/Rails 2/Tomcat 5.5

Re: Jruby/Rails 2/Tomcat 5.5

by Robert Egglestone-2 :: Rate this Message:

Reply to Author | View in Thread

Hi Russ,

Thank you for the report. I've had a look around, and previously any
unchecked exceptions would be wrapped in a ServletException and thrown up to
the container, however if the container doesn't print the trace, the message
would be lost. I've adjusted it so that now they're treated in the same way
as Ruby exceptions - the message and trace will be sent to the servlet
logger, and the message will also be passed up as a servlet exception.

Cheers,
Robert

On 16/02/08 7:51 AM, "russ olsen" <russ@...> wrote:

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



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Jruby/Rails 2/Tomcat 5.5