logo       

Re: [jruby-user] JRuby on Rails on WebSphere: msg#00216

lang.jruby.user

Subject: Re: [jruby-user] JRuby on Rails on WebSphere

Evidently WebSphere only allows you to use one of request.getParameter* or request.getInputStream, and something upstream is apparently calling one of the getParameter* methods.
http://www-1.ibm.com/support/docview.wss?uid=swg21258204
http://mail-archives.apache.org/mod_mbox/commons-user/200401.mbox/%3C20040128090742.R55740@xxxxxxxxxxxxxxxxxxx%3E

Rails/RailsServlet needed getInputStream to return a stream that had the parameters in it and that could be rewound. We changed it to pull parameters from $java_servlet_request if the input stream was empty but content-length > 0.

Our patch to action_controller is attached.


The only problem left is that the browser sometimes shows a blank page when it's supposed to, you know, show some content. It seems to be related to the "If-None-Matches", and only occur on repeated requests to the same page.


--
Matt


Stefan Magnus Landrø wrote:
Matt,

If I were you, I'd start WebSphere in debug mode and check out the IBM
implementation of the HttpServeltRequest interface. Maybe the javadocs
can give you som hints:

http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.javadoc.doc/public_html/api/index.html

HTH,

Stefan

2007/11/20, Matt Burke <maburke@xxxxxxx>:
Hello,

We're having a problem running JRuby 1.0.1 + Rails 1.2.5.7919 +
WebSphere 6.0.0.1.

The problem is that an exception is thrown whenever rails tries to parse
parameters from an HTTP POST. The stack trace in the log file looks
something like this:

/!\ FAILSAFE /!\ Mon Nov 19 11:19:14 EST 2007
Status: 500 Internal Server Error
Illegal seek
action_controller/request.rb:385:in
`parse_formatted_request_parameters'
action_controller/cgi_process.rb:83:in `request_parameters'
action_controller/request.rb:279:in `parameters'
action_controller/request.rb:19:in `method'
action_controller/routing.rb:1456:in `extract_request_environment'
action_controller/routing.rb:1397:in `recognize'
action_controller/dispatcher.rb:169:in `handle_request'
action_controller/dispatcher.rb:114:in `dispatch'
action_controller/dispatcher.rb:125:in `dispatch_cgi'
action_controller/dispatcher.rb:9:in `dispatch'
:1

I haven't figured out what exactly is throwing this exception, but it
happens when rails does (basically) this:
@cgi.stdinput.rewind

I verified that @cgi.stdinput is the same as $stdin.

$stdin is set by RailsServlet to be a RubyIO that wraps the
HttpServletRequest input stream. This makes me think that WebSphere is
returning a non-rewindable stream, since this is the only environment
where I've seen the problem. (We've also tried WebSphere CE and webrick
in jruby.) But I also noticed that RubyIO wraps InputStreams with
IOHandlerUnseekable, which throws an exception that ends up saying
"Illegal Seek" when rewind is called.

So my questions are:

(1) Why does calling rewind work in everything (WEBrick and WASCE) other
than WebSphere?

(2) Is JRuby the source of the Illegal Seek error? and should it be
throwing when we (effectively) do a $stdin.rewind?

Thanks,
Matt


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

http://xircles.codehaus.org/manage_email




diff -ruw clean/actionpack-1.13.5.7919/lib/action_controller/request.rb
patched/actionpack-1.13.5.7919/lib/action_controller/request.rb
--- clean/actionpack-1.13.5.7919/lib/action_controller/request.rb Tue Nov
27 14:40:18 2007
+++ patched/actionpack-1.13.5.7919/lib/action_controller/request.rb Wed Nov
28 16:01:46 2007
@@ -267,8 +267,8 @@
# work with raw requests directly.
def raw_post
unless env.include? 'RAW_POST_DATA'
- env['RAW_POST_DATA'] = body.read(content_length)
- body.rewind if body.respond_to?(:rewind)
+ env['RAW_POST_DATA'] = body.read(content_length) || ''
+ begin ; body.rewind if body.respond_to?(:rewind) ; rescue ; end
end
env['RAW_POST_DATA']
end
@@ -367,8 +367,12 @@
when Proc
strategy.call(body)
when :url_encoded_form
+ if body.blank? && !$java_servlet_request.nil?
+ self.class.translate_java_servlet_parameters
+ else
self.class.clean_up_ajax_request_body! body
self.class.parse_query_parameters(body)
+ end
when :multipart_form
self.class.parse_multipart_form_parameters(body, boundary,
content_length, env)
when :xml_simple, :xml_node
@@ -400,6 +404,16 @@
end.compact

UrlEncodedPairParser.new(pairs).result
+ end
+
+ def translate_java_servlet_parameters
+ pairs = $java_servlet_request.getParameterNames.inject([]) do |result,
name|
+ result + $java_servlet_request.getParameterValues(name).collect {
|value| [name, value] }
+ end
+ UrlEncodedPairParser.new(pairs).result
+ rescue => e
+ RAILS_DEFAULT_LOGGER 'Error in translate_java_servlet_parameters: ' +
e.message + "\n" + e.backtrace.join("\n")
+ {}
end

def parse_request_parameters(params)

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

http://xircles.codehaus.org/manage_email
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise