We're running our Rails application under the Glassfish gem version 1.0.2.
We've noticed a strange occurrence when doing a redirect from a Rails
before_filter; it's not clear to us if the issue is coming from JRuby or
Glassfish.
Our code checks for an authorized user and redirects to an error page if the
user is not authorized:
class ApplicationController < ActionController::Base
before_filter :authenticate
def authenticate
...authentication code here...
allow_through = SecurityAlgorithm.check_for_access
User.find(session[:user_id]), self.class, action_name
redirect_to :controller => 'home', :action => 'access_denied' unless
allow_through
end
...
When the user is authenticated but not authorized, we see the following log.
Everything goes along as expected up to the redirect, but after that for
some reason there's a response with a 302 http status code, and then a
strange ArrayIndexOutOfBoundsException coming out of the dispatcher. Any
ideas?
Feb 1, 2010 4:09:12 PM sun.reflect.GeneratedMethodAccessor1 invoke
INFO: Logging user01 in via http_basic succeeded.
Feb 1, 2010 4:09:12 PM sun.reflect.GeneratedMethodAccessor1 invoke
INFO: Denied access to basic_report/view from user01.
Feb 1, 2010 4:09:12 PM sun.reflect.GeneratedMethodAccessor1 invoke
INFO: Redirected to
http://localhost/app/access_denied
Feb 1, 2010 4:09:12 PM sun.reflect.GeneratedMethodAccessor1 invoke
INFO: Filter chain halted as [:authenticate] rendered_or_redirected.
Feb 1, 2010 4:09:12 PM sun.reflect.GeneratedMethodAccessor1 invoke
INFO: Completed in 196ms (DB: 0) | 302 Found [
http://localhost/app/basic_report_view]
Feb 1, 2010 4:09:12 PM com.sun.grizzly.jruby.RackGrizzlyAdapter
dispatchRequest
WARNING: 848
java.lang.ArrayIndexOutOfBoundsException: 848
at org.jruby.util.ByteList.hashCode(ByteList.java:632)
at org.jruby.RubyString.strHashCode(RubyString.java:1018)
at org.jruby.RubyString.hashCode(RubyString.java:1011)
at org.jruby.RubyHash.internalGetEntry(RubyHash.java:488)
at org.jruby.RubyHash.internalGet(RubyHash.java:484)
at org.jruby.RubyHash.op_aref(RubyHash.java:944)
at
org.jruby.RubyHash$i_method_1_0$RUBYINVOKER$op_aref.call(org/jruby/RubyHash$i_method_1_0$RUBYINVOKER$op_aref.gen)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:147)
at
org.jruby.ast.OpElementOneArgOrAsgnNode.interpret(OpElementOneArgOrAsgnNode.java:64)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at org.jruby.ast.IfNode.interpret(IfNode.java:119)
at org.jruby.ast.IfNode.interpret(IfNode.java:119)
at org.jruby.ast.IfNode.interpret(IfNode.java:119)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:247)
at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:204)
at
org.jruby.internal.runtime.methods.WrapperMethod.call(WrapperMethod.java:66)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:227)
at
org.jruby.ast.FCallThreeArgNode.interpret(FCallThreeArgNode.java:40)
at
org.jruby.ast.AttrAssignTwoArgNode.interpret(AttrAssignTwoArgNode.java:36)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at org.jruby.ast.IfNode.interpret(IfNode.java:119)
at org.jruby.ast.IfNode.interpret(IfNode.java:119)
at org.jruby.ast.IfNode.interpret(IfNode.java:119)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:247)
at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:204)
at
org.jruby.internal.runtime.methods.WrapperMethod.call(WrapperMethod.java:66)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:227)
at
org.jruby.ast.FCallThreeArgNode.interpret(FCallThreeArgNode.java:40)
at
org.jruby.ast.AttrAssignTwoArgNode.interpret(AttrAssignTwoArgNode.java:36)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at org.jruby.ast.IfNode.interpret(IfNode.java:119)
at org.jruby.ast.IfNode.interpret(IfNode.java:119)
at org.jruby.ast.IfNode.interpret(IfNode.java:119)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:247)
at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:204)
at
org.jruby.internal.runtime.methods.WrapperMethod.call(WrapperMethod.java:66)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:227)
at
org.jruby.ast.FCallThreeArgNode.interpret(FCallThreeArgNode.java:40)
at
org.jruby.ast.AttrAssignTwoArgNode.interpret(AttrAssignTwoArgNode.java:36)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at org.jruby.ast.IfNode.interpret(IfNode.java:119)
at org.jruby.ast.IfNode.interpret(IfNode.java:119)
at org.jruby.ast.IfNode.interpret(IfNode.java:119)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:247)
at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:204)
at
org.jruby.internal.runtime.methods.WrapperMethod.call(WrapperMethod.java:66)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:227)
at
org.jruby.ast.FCallThreeArgNode.interpret(FCallThreeArgNode.java:40)
at
org.jruby.ast.AttrAssignTwoArgNode.interpret(AttrAssignTwoArgNode.java:36)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at org.jruby.ast.IfNode.interpret(IfNode.java:119)
at org.jruby.ast.IfNode.interpret(IfNode.java:119)
at org.jruby.ast.IfNode.interpret(IfNode.java:119)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:247)
at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:204)
at
org.jruby.internal.runtime.methods.WrapperMethod.call(WrapperMethod.java:66)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:227)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.rack_minus_1_dot_0_dot_1.lib.rack.utils.parse_nested_query7319224_5114937.block_0$RUBY$__block__(utils.rb:62)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.rack_minus_1_dot_0_dot_1.lib.rack.utils.parse_nested_query7319224_5114937BlockCallback$block_0$RUBY$__block__xx1.call(Unknown
Source)
at org.jruby.runtime.CompiledBlock.yield(CompiledBlock.java:105)
at org.jruby.runtime.Block.yield(Block.java:194)
at org.jruby.RubyArray.eachCommon(RubyArray.java:1635)
at org.jruby.RubyArray.each(RubyArray.java:1642)
at
org.jruby.RubyArray$i_method_0_0$RUBYFRAMEDINVOKER$each.call(org/jruby/RubyArray$i_method_0_0$RUBYFRAMEDINVOKER$each.gen)
at
org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:116)
at
org.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:133)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.rack_minus_1_dot_0_dot_1.lib.rack.utils.parse_nested_query7319224_5114937.__file__(utils.rb:60)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.rack_minus_1_dot_0_dot_1.lib.rack.utils.parse_nested_query7319224_5114937.__file__(utils.rb)
at
org.jruby.ast.executable.AbstractScript.__file__(AbstractScript.java:47)
at
org.jruby.internal.runtime.methods.JittedMethod.call(JittedMethod.java:153)
at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:172)
at
org.jruby.internal.runtime.methods.WrapperMethod.call(WrapperMethod.java:58)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:147)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.rack_minus_1_dot_0_dot_1.lib.rack.request.POST2085457_5114937.__file__(request.rb:140)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.rack_minus_1_dot_0_dot_1.lib.rack.request.POST2085457_5114937.__file__(request.rb)
at
org.jruby.internal.runtime.methods.JittedMethod.call(JittedMethod.java:119)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:107)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.rack_minus_1_dot_0_dot_1.lib.rack.methodoverride.call8924570_5114937.__file__(methodoverride.rb:15)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.rack_minus_1_dot_0_dot_1.lib.rack.methodoverride.call8924570_5114937.__file__(methodoverride.rb)
at
org.jruby.internal.runtime.methods.JittedMethod.call(JittedMethod.java:153)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:147)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.actionpack_minus_2_dot_3_dot_5.lib.action_controller.params_parser.call2153488_5114937.__file__(params_parser.rb:15)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.actionpack_minus_2_dot_3_dot_5.lib.action_controller.params_parser.call2153488_5114937.__file__(params_parser.rb)
at
org.jruby.internal.runtime.methods.JittedMethod.call(JittedMethod.java:153)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:147)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.actionpack_minus_2_dot_3_dot_5.lib.action_controller.session.cookie_store.call8607057_5114937.__file__(cookie_store.rb:93)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.actionpack_minus_2_dot_3_dot_5.lib.action_controller.session.cookie_store.call8607057_5114937.__file__(cookie_store.rb)
at
org.jruby.internal.runtime.methods.JittedMethod.call(JittedMethod.java:153)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:147)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.actionpack_minus_2_dot_3_dot_5.lib.action_controller.failsafe.call26398519_5114937.rescue_1$RUBY$__rescue___0(failsafe.rb:26)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.actionpack_minus_2_dot_3_dot_5.lib.action_controller.failsafe.call26398519_5114937.__file__(failsafe.rb)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.actionpack_minus_2_dot_3_dot_5.lib.action_controller.failsafe.call26398519_5114937.__file__(failsafe.rb)
at
org.jruby.internal.runtime.methods.JittedMethod.call(JittedMethod.java:153)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:147)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.rack_minus_1_dot_0_dot_1.lib.rack.lock.call12958141_5114937.block_0$RUBY$__block__(lock.rb:11)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.rack_minus_1_dot_0_dot_1.lib.rack.lock.call12958141_5114937BlockCallback$block_0$RUBY$__block__xx1.call(Unknown
Source)
at org.jruby.runtime.CompiledBlock.yield(CompiledBlock.java:105)
at org.jruby.runtime.Block.yield(Block.java:194)
at
org.jruby.libraries.ThreadLibrary$Mutex.synchronize(ThreadLibrary.java:167)
at
org.jruby.libraries.ThreadLibrary$Mutex$i_method_0_0$RUBYINVOKER$synchronize.call(org/jruby/libraries/ThreadLibrary$Mutex$i_method_0_0$RUBYINVOKER$synchronize.gen)
at
org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:116)
at
org.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:133)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.rack_minus_1_dot_0_dot_1.lib.rack.lock.call12958141_5114937.ensure_1$RUBY$__ensure___0(lock.rb:11)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.rack_minus_1_dot_0_dot_1.lib.rack.lock.call12958141_5114937.__file__(lock.rb)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.rack_minus_1_dot_0_dot_1.lib.rack.lock.call12958141_5114937.__file__(lock.rb)
at
org.jruby.internal.runtime.methods.JittedMethod.call(JittedMethod.java:153)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:147)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.actionpack_minus_2_dot_3_dot_5.lib.action_controller.dispatcher.call5714024_5114937.__file__(dispatcher.rb:106)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.actionpack_minus_2_dot_3_dot_5.lib.action_controller.dispatcher.call5714024_5114937.__file__(dispatcher.rb)
at
org.jruby.internal.runtime.methods.JittedMethod.call(JittedMethod.java:153)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:147)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.glassfish_minus_1_dot_0_dot_2_minus_universal_minus_java.lib.rack.adapter.rails.call29040190_30192046.__file__(rails.rb:133)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.glassfish_minus_1_dot_0_dot_2_minus_universal_minus_java.lib.rack.adapter.rails.call29040190_30192046.__file__(rails.rb)
at
org.jruby.internal.runtime.methods.JittedMethod.call(JittedMethod.java:153)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:147)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.glassfish_minus_1_dot_0_dot_2_minus_universal_minus_java.lib.rack.handler.grizzly.call32031212_30192046.__file__(grizzly.rb:55)
at
ruby.jit.ruby.path.to.jruby.lib.ruby.gems.$1_dot_8.gems.glassfish_minus_1_dot_0_dot_2_minus_universal_minus_java.lib.rack.handler.grizzly.call32031212_30192046.__file__(grizzly.rb)
at
org.jruby.internal.runtime.methods.JittedMethod.call(JittedMethod.java:153)
at org.jruby.RubyClass.finvoke(RubyClass.java:568)
at
org.jruby.javasupport.util.RuntimeHelpers.invoke(RuntimeHelpers.java:409)
at org.jruby.RubyBasicObject.callMethod(RubyBasicObject.java:317)
at
com.sun.grizzly.jruby.rack.AbstractRackApplication.call(AbstractRackApplication.java:156)
at
com.sun.grizzly.jruby.RackGrizzlyAdapter.dispatchRequest(RackGrizzlyAdapter.java:335)
at
com.sun.grizzly.jruby.RackGrizzlyAdapter.service(RackGrizzlyAdapter.java:322)
at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:166)
at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:100)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:245)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:619)
--