views:

8

answers:

0

Hello All:

Wondering if anyone has come across this issue before, I am using JRuby v 1.5.x and Rails 2.5.x on a Tomcat Server and I am having difficulty capturing an error and redirecting to a 500.html page. Here is a stacktrace. I attempt to capture the error state but to no avail, it goes immediately to rendering the web page. (Attempted code snippets follow below).

Stacktrace

BlahBlahController::create -- .....
  RssFeed Load (0.0ms) NativeException: java.sql.SQLException: Closed Connection: select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM rss_feeds WHERE (abbr = 'TEST1') ) raw_sql_ where rownum <= 1) where raw_rnum_ > 0

ActiveRecord::StatementInvalid (NativeException: java.sql.SQLException: Closed Connection: select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM XXXX WHERE (abbr = 'TEST1') ) raw_sql_ where rownum <= 1) where raw_rnum_ > 0):
  /opt/springsource/tcServer-6.0/instances/tc_instance3/webapps/appX/WEB-INF/gems/gems/activerecord-oracle_enhanced-adapter-1.2.4/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1591:in `log'
  /opt/springsource/tcServer-6.0/instances/tc_instance3/webapps/appX/WEB-INF/gems/gems/activerecord-oracle_enhanced-adapter-1.2.4/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1487:in `select'
  app/controllers/blah_blah_controller.rb:66:in `create'
  file:lib/jruby-rack-1.0.1.jar!/vendor/rack-1.1.0/rack/head.rb:9:in `call'
  file:lib/jruby-rack-1.0.1.jar!/vendor/rack-1.1.0/rack/methodoverride.rb:24:in `call'
  file:lib/jruby-rack-1.0.1.jar!/vendor/rack-1.1.0/rack/lock.rb:11:in `call'
  file:lib/jruby-rack-1.0.1.jar!/rack/adapter/rails.rb:36:in `serve_rails'
  file:lib/jruby-rack-1.0.1.jar!/rack/adapter/rails.rb:41:in `call'
  file:lib/jruby-rack-1.0.1.jar!/jruby/rack/rails.rb:180:in `call'
  file:lib/jruby-rack-1.0.1.jar!/rack/handler/servlet.rb:19:in `call'
  :1

Rendering /opt/springsource/tcServer-6.0/instances/tc_X/webapps/appX/500.html (500 Internal Server Error)

I when I inspect the HTTP Header I see the following

HTTP/1.1 500 Internal Server Error
Cache-Control: no-cache
Connection: close
Date: xxxx
Server: Apache-Coyote/1.1

Here is some of the coding attempts I have performed.

ActionController Code

Attempt 1

  def rescue_action_in_public(exception)
      Rails.logger.error "ApplicationController::rescue_action_in_pubic -- Exception occurred"
      Rails.logger.error "ApplicationController::rescue_action_in_pubic -- Exception = '#{exception.to_s}'"
      Rails.logger.error "ApplicationController::rescue_action_in_pubic -- Stack\n#{exception.backtrace}\n"
       render :xml => create_xml_response(), :status => 500
    end

Attempt 2

  unless ActionController::Base.consider_all_requests_local
    rescue_from Exception,                            :with => :render_error
    rescue_from ActionController::RoutingError,       :with => :render_error
    rescue_from ActionController::UnknownController,  :with => :render_error
    rescue_from ActionController::UnknownAction,      :with => :render_error
    rescue_from ActiveRecord::StatementInvalid,       :with => :render_error
  end


 private

  def render_error(exception)
    Rails.logger.exception "*************** CRITICALITY *******************************"
    Rails.logger.exception "The following exception occurend in the application."
    ...
    Rails.logger.exception "*************** CRITICALITY *******************************"
    render :xml => create_xml_response(), :status => 500
  end

Am I missing something in a controller, a model? Could this be an issue addressed in a newer version of a Gem?

Any help or guidance would be greatly appreciated!

-Jason