Exception in ActionController::Base:Class for "first request only"

Hi,

I am running Rails 3.0 with Ruby 1.9.2 (compiled from source) on
Ubuntu 10.04.1 (Lucid Lynx) 32-bit.

About a week back I started seeing this weird exception for a
particular request and that too only for the “first time”, every time
after I restart my server (WEBrick in this case). All subsequent
requests are fine. If the same request made again, it works fine.

Here is the exception and stack trace that is printed to the console :
http://pastie.org/2110523

To me it appears like parts of the actionpack gem are not being loaded
properly and hence the no_method_error.
I could not figure out anything more. Any help in understanding the
cause of the error and a way to solve it is greatly appreciated.

Here are some things that I tried (the results of which made
absolutely no sense to me) :

The request is http://localhost/user

This is a simple query (AJAX request if that matters) to check if the
user is logged in. If the user is indeed logged in then it returns
some basic user info or it returns an error status code if not. When
the website home page is loaded, this is the first request to the
rails application (after several static files have been served by
Nginx).

Setup 1 – I have NginX in front of WEBrick. NginX is listening on
port 80 and forwarding requests to WEBrick ====== listening on port
3000

Experiment 1

  1. Start WEBrick

  2. Load the home page in a browser (I am using Firefox 4.0.1)
    — Exception on the first request (the request info (like the path,
    params if any, etc, etc) is also not printed)
    — Subsequent requests are fine.

  3. Refresh the page
    — Everything works fine, including the first request to “/user”

  4. Restart WEBrick

  5. Refresh the page again
    — Same behavior (exception raised) as seen in Step 2

Experiment 2

  1. Start WEBrick

  2. Load the home page
    — First request errors out (as seen in Step 2 of previous scenario).
    Ignore it.

  3. Restart the WEBrick

  4. Make the same AJAX query for “/user” using firebug
    — Works absolutely fine. Unlike the Step 5 of previous scenario,
    this doesn’t result in an exception.

Experiment 3

  1. Start WEBrick
  2. Make a direct “/user” request using the “Poster” add-on (i.e.
    basically avoid loading the static resources)
    — Works absolutely fine. No error, unlike the previous two
    scenarios.

These experiments and observations have left me totally clueless.

From the stack trace it appears that the problem is within the
actionpack gem as both the calling method and the method being called
(and not_found) are in that gem (in fact within ActionController
namespace).

Thank you.