When forming redirect to login page response for ajax request, URL does not contain the context path.
The patch is attached.
Implemented by Alex Kochnev in r2557. Alex, this bug was open before your fix so you have to refer to it in the commit. Vladimir, argue hard if you want this in 0.4.7, otherwise just upgrade to 0.5.1 once released.