jruby / jruby-rack

Rack for JRuby and Java appservers
MIT License
397 stars 137 forks source link

not working with servlet < 3.0 (e.g. tomcat 6) ? #177

Closed kares closed 10 years ago

kares commented 10 years ago

trace details copied from https://github.com/jruby/warbler/issues/274

java.lang.AbstractMethodError: org.apache.catalina.connector.RequestFacade.getServletContext()Ljavax/servlet/ServletContext;
    javax.servlet.ServletRequestWrapper.getServletContext(javax/servlet/ServletRequestWrapper.java:398)
    java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:606)
    RUBY.servlet_context(file:/var/lib/tomcat6/webapps/jruby-rails/WEB-INF/lib/jruby-rack-1.1.14.jar!/rack/handler/servlet/default_env.rb:238)
    RUBY.load_builtin(file:/var/lib/tomcat6/webapps/jruby-rails/WEB-INF/lib/jruby-rack-1.1.14.jar!/rack/handler/servlet/default_env.rb:206)
    RUBY.load_env_key(file:/var/lib/tomcat6/webapps/jruby-rails/WEB-INF/lib/jruby-rack-1.1.14.jar!/rack/handler/servlet/default_env.rb:151)
    RUBY.key?(file:/var/lib/tomcat6/webapps/jruby-rails/WEB-INF/lib/jruby-rack-1.1.14.jar!/rack/handler/servlet/default_env.rb:91)
    RUBY.load_builtins(file:/var/lib/tomcat6/webapps/jruby-rails/WEB-INF/lib/jruby-rack-1.1.14.jar!/rack/handler/servlet/default_env.rb:123)
    org.jruby.RubyArray.each(org/jruby/RubyArray.java:1613)
    RUBY.load_builtins(file:/var/lib/tomcat6/webapps/jruby-rails/WEB-INF/lib/jruby-rack-1.1.14.jar!/rack/handler/servlet/default_env.rb:122)
    RUBY.populate!(file:/var/lib/tomcat6/webapps/jruby-rails/WEB-INF/lib/jruby-rack-1.1.14.jar!/rack/handler/servlet/default_env.rb:71)
    RUBY.populate(file:/var/lib/tomcat6/webapps/jruby-rails/WEB-INF/lib/jruby-rack-1.1.14.jar!/rack/handler/servlet/default_env.rb:64)
    RUBY.create(file:/var/lib/tomcat6/webapps/jruby-rails/WEB-INF/lib/jruby-rack-1.1.14.jar!/rack/handler/servlet/default_env.rb:43)
    RUBY.create_env(file:/var/lib/tomcat6/webapps/jruby-rails/WEB-INF/lib/jruby-rack-1.1.14.jar!/rack/handler/servlet.rb:26)
    RUBY.call(file:/var/lib/tomcat6/webapps/jruby-rails/WEB-INF/lib/jruby-rack-1.1.14.jar!/rack/handler/servlet.rb:22)

https://github.com/jruby/jruby-rack/blob/master/src/main/ruby/rack/handler/servlet/default_env.rb#L238

samsonw commented 10 years ago

I'm on JRuby 1.7.13/JRuby-Rack 1.1.14/Tomcat 6.0.37, with code:

puts request.env['java.servlet_context']
puts request.env['java.servlet_context'].inspect

I get the result below during the request:

org.jruby.rack.servlet.DefaultServletRackContext@4af95a9
#<Java::OrgJrubyRackServlet::DefaultServletRackContext:0x4af95a9>

Let me know if you need more debug output.

kares commented 10 years ago

Thanks Samson - much appreciated, had a hard time reproducing jruby/warbler#274 myself on TC6 ...