Ruby Forum JRuby > Rack servlet filter failure on AIX 5.3 Websphere 6.1.0.11

Posted by Wes Gamble (weyus)
on 18.08.2008 18:49
(Received via mailing list)
Rack 0.3.0
Merb 0.9.4
Warbler 0.9.10

This is more of an FYI than anything - I suspect that it is related to
the following Websphere issue
(http://www-1.ibm.com/support/docview.wss?uid=swg24017226).

Websphere has a specific problem where a special custom property
(com.ibm.ws.webcontainer.invokefilterscompatibility) has to be set to
true for the Web container to even allow servlet filters to be run.
I've done this.

When I attempt to use the Rack filter setup in warbler for my Merb app.,
I get the exception:  "SRVE0209E: Writer already obtained" (the entire
stack trace is below).  It occurs at line 44 of
jruby/rack/servlet_helper.rb.  This is where the response is being
written ("write_body(response)").  Clearly the call to getOutputStream
in the "write_body" method is failing.

Is a way to patch around this so that if a writer already exists, it can
be detected?  My servlet - fu is old and weak, and I don't remember if
there is a way to do that or not.

Thanks,
Wes


======= Stack Trace =========

[8/18/08 10:52:32:219 CDT] 00000025 WebApp        A   SRVE0181I:
[merb_test_war#merb_test.war] [/merb_test] [Servlet.LOG]: Exception
caught: com/ibm/ws/webcontainer/srt/SRTServletResponse.java:538:in
`getOutputStream': java.lang.IllegalStateException: SRVE0209E: Writer
already obtained (NativeException)
        from sun/reflect/NativeMethodAccessorImpl.java:-2:in `invoke0'
        from sun/reflect/NativeMethodAccessorImpl.java:64:in `invoke'
        from sun/reflect/DelegatingMethodAccessorImpl.java:43:in 
`invoke'
        from java/lang/reflect/Method.java:615:in `invoke'
        from org/jruby/javasupport/JavaMethod.java:250:in
`invokeWithExceptionHandling'
        from org/jruby/javasupport/JavaMethod.java:219:in `invoke'
        from org/jruby/javasupport/JavaClass.java:416:in `execute'
        from
org/jruby/internal/runtime/methods/SimpleCallbackMethod.java:67:in 
`call'
         ... 67 levels...
        from
file:/home/bassel/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/leasrv014Node01Cell/merb_test_war.ear/merb_test.war/WEB-INF/lib/jruby-rack-0.9.1.jar!/jruby/rack/servlet_helper.rb:44:in
`respond'
        from
file:/home/bassel/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/leasrv014Node01Cell/merb_test_war.ear/merb_test.war/WEB-INF/lib/jruby-complete-1.1.3.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/builtin/javasupport/proxy/interface.rb:174:in
`__jcreate_proxy!'
        from :1
Complete Java stackTrace
java.lang.IllegalStateException: SRVE0209E: Writer already obtained
        at
com.ibm.ws.webcontainer.srt.SRTServletResponse.getOutputStream(SRTServletResponse.java:538)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:615)
        at
org.jruby.javasupport.JavaMethod.invokeWithExceptionHandling(JavaMethod.java:250)
        at org.jruby.javasupport.JavaMethod.invoke(JavaMethod.java:219)
        at
org.jruby.javasupport.JavaClass$InstanceMethodInvoker.execute(JavaClass.java:416)
        at
org.jruby.internal.runtime.methods.SimpleCallbackMethod.call(SimpleCallbackMethod.java:67)
        at
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:224)
        at
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:201)
        at
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:123)
        at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:333)
        at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:61)
        at org.jruby.ast.LocalAsgnNode.interpret(LocalAsgnNode.java:115)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:101)
        at org.jruby.ast.BlockNode.interpret(BlockNode.java:67)
        at
org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:171)
        at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:147)
        at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:266)
        at
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:147)
        at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:384)
        at 
org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:101)
        at org.jruby.ast.BlockNode.interpret(BlockNode.java:67)
        at org.jruby.ast.IfNode.interpret(IfNode.java:110)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:101)
        at
org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:171)
        at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:147)
        at org.jruby.RubyObject.send(RubyObject.java:2050)
        at org.jruby.RubyObjectInvoker$send_method_0_0.call(Unknown 
Source)
        at
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:134)
        at
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:111)
        at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:282)
        at org.jruby.ast.CallNode.interpret(CallNode.java:163)
        at 
org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:101)
        at org.jruby.ast.BlockNode.interpret(BlockNode.java:67)
        at
org.jruby.runtime.InterpretedBlock.evalBlockBody(InterpretedBlock.java:203)
        at
org.jruby.runtime.InterpretedBlock.yield(InterpretedBlock.java:191)
        at org.jruby.runtime.BlockBody.call(BlockBody.java:64)
        at org.jruby.runtime.Block.call(Block.java:96)
        at org.jruby.RubyProc.call(RubyProc.java:202)
        at org.jruby.RubyProc.call(RubyProc.java:189)
        at org.jruby.javasupport.Java$5.invoke(Java.java:1165)
        at $Proxy18.respond(Unknown Source)
        at
org.jruby.rack.DefaultRackDispatcher.process(DefaultRackDispatcher.java:32)
        at org.jruby.rack.RackFilter.doFilter(RackFilter.java:51)
        at
com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
        at
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
        at
com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
        at
com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:761)
        at
com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:673)
        at
com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:688)
        at
com.ibm.ws.wswebcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:101)
        at
com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.invokeFilters(DefaultExtensionProcessor.java:758)
        at
com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:718)
        at
com.ibm.ws.wswebcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:113)
        at
com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3276)
        at
com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267)
        at
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
        at
com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1455)
        at
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:113)
        at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
        at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:383)
        at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:263)
        at
com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
        at
com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
        at
com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
        at
com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
        at
com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
        at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
        at 
com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
        at
com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
        at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
        at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)
        ...internal jruby stack elided...


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

    http://xircles.codehaus.org/manage_email
Posted by Wes Gamble (weyus)
on 18.08.2008 23:36
(Received via mailing list)
Wes Gamble wrote:
> Is a way to patch around this so that if a writer already exists, it 
> [merb_test_war#merb_test.war] [/merb_test] [Servlet.LOG]: Exception 
>        from org/jruby/javasupport/JavaClass.java:416:in `execute'
>        from 
> org/jruby/internal/runtime/methods/SimpleCallbackMethod.java:67:in `call'
>         ... 67 levels...
>        from 
> file:/home/bassel/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/leasrv014Node01Cell/merb_test_war.ear/merb_test.war/WEB-INF/lib/jruby-rack-0.9.1.jar!/jruby/rack/servlet_helper.rb:44:in 
> `respond'
>        from 
> file:/home/bassel/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/leasrv014Node01Cell/merb_test_war.ear/merb_test.war/WEB-INF/lib/jruby-complete-1.1.3.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/builtin/javasupport/proxy/interface.rb:174:in 
> `__jcreate_proxy!'
>
An update to the latest version of Websphere on AIX (6.1.0.17) does not
solve this problem.

Wes

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

    http://xircles.codehaus.org/manage_email
Posted by Wes Gamble (weyus)
on 18.08.2008 23:52
(Received via mailing list)
Wes Gamble wrote:
>> getOutputStream in the "write_body" method is failing.
>> Is a way to patch around this so that if a writer already exists, it 
>> can be detected?  My servlet - fu is old and weak, and I don't 
>> remember if there is a way to do that or not.
Please forgive me for responding to my own post, not once, but twice.

I've combed through the source code for jruby-rack and I can only find
one occurrence of response.getWriter() or response.getOutputStream() in
the code and that is a call to response.getOutputStream that fails.  It
makes me think that Websphere has some sort of default servlet filter
that I don't know about or filter wrapper or something that is pulling a
writer/output stream before the JRuby-Rack code runs.

I give up.  No RackFilter on Websphere.  RackServlet instead.

Wes

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

    http://xircles.codehaus.org/manage_email