Mura Railo ErrorCode 0 Page not Found

In Mura sites on Railo, if one attempts to access a non-existent .CFM template, then an interesting error occurs. A Railo error page returns with an ErrorCode of 0. The message states, Page {requested template} not Found. This should be a 404 and not 0.

For example take a look at http://www.cfeclipse.org/about.cfm. There is no about.cfm on cfeclipse.org.

http://www.cfeclipse.org/about.cfm http://www.cfeclipse.org/about.cfm throws a Railo ErrorCode 0 and NOT a 404

Doesn't that look like it should return an ErrorCode 404?

Let's take a look at the response header: http://www.cfeclipse.org/about.cfm response header of 200 OK

This is why we are not getting any Tomcat or Railo 404 error interception.

Initially I went to the Railo Administrator Error Settings and played around there. This had no effect on this anomaly. But this is because, as you recall, that the response header reports a 200 OK. Not 404 or any other error. Thus, it's a Mura deal.

I did find a satisfactory solution based on an old Mura form post.

In {siteroot}/{siteID}/includes/eventHandler.cfc, I added this function:

view plain print about
1<cffunction name="onApplicationLoad" output="true" returntype="any">
2    <cfargument name="$">
3
4    <cfset var customHandler=createObject("component","customHandler").init()>
5    <cfset getBean("pluginManager").addEventHandler(customHandler,$.event('siteID'))>
6</cffunction>

I then created {siteroot}/{siteID}/includes/customHandler.cfc which looks like:

view plain print about
1<cfcomponent extends="mura.cfobject">
2    <cffunction name="onGlobalMissingTemplate" output="true" returntype="any">
3        <cfargument name="$">
4        <cflocation url="/" addtoken="false" />
5        <cfabort>
6        <!--- you could also set $.event("__MuraResponse__","true") instead of using the cfabort.--->
7    </cffunction>
8</cfcomponent>

It works great (so far!) and I have all Mura Page Not Founds going to the local site root (using cflocation) which is OK with me, instead of a custom error.

A concern that crept up was that when I do a Mura "Update Core Files", the changes will be overwritten. Well, I have been assured that eventHandler.cfc remains untouched during any Mura upgrades.

Next will be to create a Mura Plugin so that I will not have to edit code to change my Page Not Found response page as well as share with the Mura community.

Mura Custom 404 Error Page

How do I create a custom 404 error template or page in Mura?

Oh man, this is so easy.

  1. Go to your Mura Admin, Site Manager.
  2. Add a page under your home page.
  3. Name it 404.
  4. Uncheck the Include in Site Navigation.
  5. Go to the Advanced tab and make sure it is not in Site Search
  6. Put in whatever code or notes you want to make it look good and have the idiot feel better about getting a 404.

Railo Tomcat Custom 404

How do I add a custom 404 error page for Railo Tomcat?

In your {Railo Tomcat}/conf/web.xml, mine, on Ubuntu is /opt/railo/tomcat/conf/web.xml, down at the very bottom under the welcome-file-list add this:

view plain print about
1snipped
2.....
3 </welcome-file-list>
4
5 <error-page>
6 <error-code>404</error-code>
7 <location>/MyErrorDir/MyCustom404.cfm</location>
8 </error-page>

The path to your custom 404 CFM template should be relative to your site's root. If you have multiple sites, each should have the same path.

Railo Tomcat 404 redirects and CGI vars

I've run into an issue with 404 redirects on Ubuntu - Railo - Tomcat (no Apache).

I have the site's /WEB-INF/web.xml redirecting 404 errors to a custom 404.cfm which tries to read and act on certain CGI variables. The problem is that I'm not getting all the CGI variables, most are null. The QUERY_STRING is the only variable passed from the missing template. The rest are either null or for the 404.cfm.

What I want is the template path and query string of the missing template.

Here are some of the cfdumps I've tried:

view plain print about
1<cfdump var="#cgi#">
2<cfdump var="#getPageContext().getRequest()#"><!--- returns HTTPServletRequestWrap class, fields, methods --->
3<cfdump var="#getPageContext().getRequest().getOriginalRequest()#"><!--- returns ApplicationHttpRequest class, fields, methods --->
4<cfdump var="#getPageContext().getRequest().getOriginalRequest().getAttributeNames()#"><!--- returns apparently useable strings --->
5<cfdump var="#getPageContext().getRequest().getOriginalRequest().getAttribute("query_string")#"><!--- returns Empty:null --->
6<cfdump var="#getPageContext().getRequest().getOriginalRequest().getParameterNames()#"><!--- returns "id" --->
7<cfdump var="#getPageContext().getRequest().getOriginalRequest().getHeaderNames()#"><!--- returns apparently useable strings --->
8<cfdump var="#getPageContext().getRequest().getOriginalRequest().getQueryString()#"><!--- returns original template's query string Yay! --->
9<cfdump var="#getPageContext().getRequest().getOriginalRequest().getRequestURL()#"><!--- returns URL for 404.cfm --->
10<cfdump var="#getPageContext().getRequest().getOriginalRequest().getAttribute("Referer")#"><!--- returns Empty:null --->
11<cfdump var="#getPageContext().getRequest().getOriginalRequest().getAttribute("Redirect_URL")#"><!--- returns Empty:null --->

Any ideas would be GREATLY appreciated. Remember, Tomcat is the web server without Apache.

BlogCFC was created by Raymond Camden. This blog is running version 5.9.7. Contact Blog Owner