[Mongrel] GET request works via curl, crashes from Java

Eden Li eden.li at gmail.com
Wed Jan 31 01:22:03 EST 2007


You can tell mongrel to go into debug mode by passing in "-B" on the
command line to "mongrel_rails start".  It'll start logging requests
to the console like WEBrick, and it'll log a ton of info to
log/mongrel_debug.

Although, in your case, I would recommend firing up some sort of HTTP
traffic sniffer.  It'll give you way more information.  Live HTTP
Headers in Firefox may work in your case (but only if you want headers
of the conversation, apropos to its name).  Wireshark works well if
you're in Linux, and Fiddler's a good tool for Windows users.  I have
no clue what a Mac OS X user would use, but there's probably something
out there.

On 1/31/07, Stephen Bannasch <stephen at concord.org> wrote:
> [That subject line is of course a severe truncation!]
>
> I've got a REST request that works fine from curl but causes a
> mongrel error when executed from a Java program. This all worked with
> fine with rails 1.1.6 and webrick. I'm trying to update the app to
> rails 1.2.1 (I need working around_filters).
>
> I'm running in development mode with mongrel 1.01 running on macosx
> 10.4.8 w/ruby 1.8.4, rails 1.2.1.
>
> When I do the following request with curl everything appears to work fine:
>
> curl -I -X GET -H 'Accept: application/xml'
> http://localhost:3000/1/offering/84/bundle/168/0
>
>    HTTP/1.1 200 OK
>    Connection: close
>    Date: Wed, 31 Jan 2007 04:41:24 GMT
>    Status: 200 OK
>    Cache-Control: no-cache
>    Server: Mongrel 1.0.1
>    Content-Type: text/xml; charset=utf-8
>    Content-Length: 2706
>
> However when I try what is supposed to be the same request made from
> a Java jnlp application mongrel reports this error:
>
>    You have a nil object when you didn't expect it!
>    You might have expected an instance of ActiveRecord::Base.
>    The error occurred while evaluating nil.update
>
> /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/request.rb:13:in
> `parameters'
>
> /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/request.rb:20:in
> `method'
>
> /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/routing.rb:1307:in
> `extract_request_environment'
>
> /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/routing.rb:1256:in
> `recognize'
>
> /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/dispatcher.rb:40:in
> `dispatch'
>
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:78:in
> `process'
>
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in
> `process'
>
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:618:in
> `process_client'
>
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in
> `process_client'
>    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
>    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
>    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `run'
>
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:271:in
> `run'
>
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in
> `run'
>
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:127:in
> `run'
>
> /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/command.rb:211:in
> `run'
>    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:243
>
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:489:in
> `load'
>
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:343:in
> `new_constants_in'
>
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:489:in
> `load'
>
> /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/commands/servers/mongrel.rb:60
>    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
>
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:496:in
> `require'
>
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:343:in
> `new_constants_in'
>
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:496:in
> `require'
>    /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/commands/server.rb:39
>    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
>
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:496:in
> `require'
>
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:343:in
> `new_constants_in'
>
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:496:in
> `require'
>    script/server:3
>
> Here's the code in request.rb:
>
>    # Returns both GET and POST parameters in a single hash.
>    def parameters
>      @parameters ||=
> request_parameters.update(query_parameters).update(path_parameters).with_indifferent_access
>    end
>
> The Java program is expecting an xml file and obviously isn't getting
> what it is supposed to:
>
>    org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Content
> is not allowed in prolog.
>
> I thought it was unlikely to be helpful but I turned $mongrel_debug_client:
>
>    kill -USR1 900
>
> This appeared in the mongrel_log but nothing else:
>
>    ** USR1 received, toggling $mongrel_debug_client to true
>
> I'm not able to get the Java program to log any more info about just
> what request it made until I can get ion touch with the programmer.
>
> Somehow I'm stuck thinking there must be a difference in the actual
> http requests (though their shouldn't be).
>
> The result from the Java request using webrick in 1.2.1 is also an
> error and is similar to a warning in he Mongrel FAQ page:
>
> The request from curl via webrick:
>
>    127.0.0.1 - - [31/Jan/2007:00:50:43 EST] "GET
> /1/offering/84/bundle/168/0 HTTP/1.1" 200 2706
>
> The request from Java via webrick:
>
>    127.0.0.1 - - [31/Jan/2007:00:51:43 EST] "GET
> /1/offering/84/bundle/168/0 HTTP/1.1" 500 309
>
> The error occurs in the same place in request.rb in Webrick so this
> isn't mongrel specific.
>
> Is there a way I can get mongrel to log more about the http request
> so I can compare the two in more detail?
>
> I was able to set a breakpoint in the rails controller method and get
> detailed info from rails about the request that worked. But none of
> my breakpoints get touched with the request that causes the error.
>
> Thanks for any help or pointers.
>
> --
> - Stephen Bannasch
>    Concord Consortium, http://www.concord.org
> _______________________________________________
> Mongrel-users mailing list
> Mongrel-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-users
>


More information about the Mongrel-users mailing list