Railo mailing list thread: http://groups.google.com/group/railo/browse_thread/thread/38e4b868dd8ff979
The problem is described in the following text, and in short it is: "cgi.redirect_url and cgi.redirect_query_string are not available in the cgi scope of railo, while Apache does set them. This happens when mod_jk is used between apache and tomcat+railo".
I have an Apache webserver, which connects to tomcat+railo via mod_jk. This works.
I have a virtualhost setup as follows:
ErrorDocument 404 /404error.cfm
Now, if I call a non-existing page http://localhost/page-does-not-exist, then Apache creates some extra "cgi variables", for example "cgi.redirect_url" and "cgi.redirect_query_string", and then calls the 404 handler /404error.cfm.
The code in 404error.cfm then checks those cgi variables to determine which url was requested, and then does other stuff, like showing a 404.
Now, in this mod_jk setup, these variables seemed to be gone. They are always an empty string (as with all undefined cgi vars).
So I tried using "JkEnvVar" in Apache's httpd.conf, to explicitly send those cgi vars, but that didn't help. I asked mister google for another 100 options, but didn't help.
Then I dug a little deeper, and checked the request itself:
<cfdump var="#getPageContext().getRequest().getAttribute('REDIRECT_URL')#" />
That gave a Null back.
But it had an interesting method getOriginalRequest(), so I tried:
<cfdump var="#getPageContext().getRequest().getOriginalRequest().getAttribute('REDIRECT_URL')#" />
And voila! There it was: "/page-does-not-exist".
This originalRequest is of type "org.apache.catalina.connector.RequestFacade" btw,a nd the getRequest is of type "railo.runtime.net.http.HTTPServletRequestWrap".
So now I know where I can digg those variables up, so my 404 page will work.
But here's the bug/missing feature: shouldn't these variables already be available in the cgi scope? I think they should, because that's how it works when I used ACF / Resin+Railo behind an Apache webserver. I know that it will break some people's 404 code, especially if mod_jk will be used in the default railo installs.