jruby/jruby-rack — Issue #88: undefined method `log' for nil:NilClass
Author: jingweno
Created: 2012-01-30 23:22:30+00:00
State: open

Hi,

I have a sinatra app and try to log some messages in the controller, here is some sample code:

```ruby
get '/foo' do
logger.info('foo')
end
```

I am using Trinidad as the application server. And here is the exception I got from the stacktrace.

```bash
Error: Couldn't handle error: response committed
org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `log' for nil:NilClass
at JRuby::Rack::ServletLog.write(file:/Users/oou/.rvm/gems/jruby-1.6.6/gems/jruby-rack-1.1.3/lib/jruby-rack-1.1.3.jar!/jruby/rack/servlet_log.rb:18)
at Rack::CommonLogger.log(/Users/oou/.rvm/gems/jruby-1.6.6/gems/rack-1.4.1/lib/rack/commonlogger.rb:39)
at Rack::CommonLogger.call(/Users/oou/.rvm/gems/jruby-1.6.6/gems/rack-1.4.1/lib/rack/commonlogger.rb:22)
at org.jruby.RubyProc.call(org/jruby/RubyProc.java:258)
at Rack::BodyProxy.close(/Users/oou/.rvm/gems/jruby-1.6.6/gems/rack-1.4.1/lib/rack/body_proxy.rb:17)
at JRuby::Rack::Response.write_body(file:/Users/oou/.rvm/gems/jruby-1.6.6/gems/jruby-rack-1.1.3/lib/jruby-rack-1.1.3.jar!/jruby/rack/response.rb:111)
at JRuby::Rack::Response.respond(file:/Users/oou/.rvm/gems/jruby-1.6.6/gems/jruby-rack-1.1.3/lib/jruby-rack-1.1.3.jar!/jruby/rack/response.rb:50)
Error: Couldn't handle error: response committed
org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `log' for nil:NilClass
at JRuby::Rack::ServletLog.write(file:/Users/oou/.rvm/gems/jruby-1.6.6/gems/jruby-rack-1.1.3/lib/jruby-rack-1.1.3.jar!/jruby/rack/servlet_log.rb:18)
at Rack::CommonLogger.log(/Users/oou/.rvm/gems/jruby-1.6.6/gems/rack-1.4.1/lib/rack/commonlogger.rb:39)
at Rack::CommonLogger.call(/Users/oou/.rvm/gems/jruby-1.6.6/gems/rack-1.4.1/lib/rack/commonlogger.rb:22)
at org.jruby.RubyProc.call(org/jruby/RubyProc.java:258)
at Rack::BodyProxy.close(/Users/oou/.rvm/gems/jruby-1.6.6/gems/rack-1.4.1/lib/rack/body_proxy.rb:17)
at JRuby::Rack::Response.write_body(file:/Users/oou/.rvm/gems/jruby-1.6.6/gems/jruby-rack-1.1.3/lib/jruby-rack-1.1.3.jar!/jruby/rack/response.rb:111)
at JRuby::Rack::Response.respond(file:/Users/oou/.rvm/gems/jruby-1.6.6/gems/jruby-rack-1.1.3/lib/jruby-rack-1.1.3.jar!/jruby/rack/response.rb:50)
```

Thanks,
Owen