You can reference here for a Site aware exception handling in Magnolia CMS which is updated for Magnolia CMS 5.7.+
The 404 Handler
In some projects you may want to have the possibility to define your own Error-Pages (as 404 etc.).
With magnolia it is either possible to define this pages internally in the website tree, or externally.
Since magnolia 3.5 (magnolia internal error page)
If you are using Tomcat/Jboss you can do so by simple edit the magnoliaPublic
and add the following section:
When using a single installation with multiple domains, host based virtual URI mapping might be useful:
A 500 Internal Server Error might best be served without relying on Magnolia. Hence:
After your application server restarted, the error page will now come out of magnolia (with all it's benefits).
If you have an older version of magnolia or, for whatever reasons, want to have your error page outside of magnolia you can do this as well following the procedure below.
Before magnolia 3.5 (external/redirected error page)
For this example let's assume that your magnolia site is under /index/
and that you have created your own 404.html error page under that..ie
Edit the magnoliaPublic
and add the following section:
Now, create a 404.jsp file inside your \webapps\magnoliaPublic\admintemplates directory
that contains the following jsp code
What will happen is that if a user requests a page that doesn't exist inside
your magnoliaPublic context then Tomcat will redirect the user to the
/admintemplates/404.jsp page which then redirects to your
Why must you do it this way?? Well, your
web.xml has to point to a file that actually exists somewhere in your
webapps directory, not to a 'virtual' file in your Magnolia repository. If you doubt this, try replacing
/magnoliaPublic/index/404.html and see what happens. We point the
web.xml to a 'real' file and then have that real file perform a redirect to your magnolia generated 404.html file.
Please note here, that when you are redirecting the error page, the page header received by the request will no longer by 404 but 302 instead. This may lead to some issues with search engines, like with google for example.
When using this with Magnolia 3.5.x
Now to make this work with Magnolia v3.5.x you need to define a bypass for a custom jsp page created above.
When configuring bypass all the values are applied immediately. In other words, your filter will be applied before it is configured, resulting in a completely broken configuration. Hence you must configure this node elsewhere in the tree and only when fully configured move it to (
Read what you can do if your bypass configuration is broken.
Go to the configuration menu and create new contentNode anywhere but not at
server/filters/bypasses and call it
404 for this node create dataNode
class and set it to
info.magnolia.voting.voters.URIStartsWithVoter and dataNode
pattern with value pointing to your
/admintemplates/404.jsp in the case of example above). Once configured, move your node to
In its previous incarnation on JspWiki, this page was last edited on Mar 31, 2007 10:07:56 PM by Magnolia
Other known authors include :