Search code examples
javaurldefaultwildfly-8servlet-3.0

How to set a default error page for WildFly server?


I'm using Wildlfy Application Server 8.2.0.Final. I have deployed an app.war file. In app's web.xml I can specify a home page and error pages. Which works perfectly for

local-host.com/app

url and for incorrect urls relative to it. When i type something like

local-host.com/app/xxx

I can see the specified page - that's great.

But when I enter

local-host.com

I can see WildFly's default page and when I type an incorrect one

local-host.com/xxx

I will se just 404 - Not Found

I would love to use same welcome and error pages from my app for these urls. I have found a reasonable solution for the welcome page here: How to auto direct to "my web application" from "root (/)" context in JBoss? which works fine, but I couldn't find out what can I do with errors.

Zigac's solution works great and mine "manual" solution works as well, but there is still an issue:

What to do with

local-host.com/META-INF

url - I still get server's default error message for it even despite that the url is under app's root?

Thx.


Solution

  • I changed localhost alias setting for WildFly's HTTP server and specified my app's war instead of the default root.war. This solution unlike the one with redirecting to my app's url from the default app server's index.html(in welcome-content directory) allows all the "/" related urls be interpreted as my app's related urls and thus the provided error pages mapping from app.war web.xml works perfectly for all incorrect urls.

    I used WildFly's administration console(9090) to change HTTP server settings: Configuration -> Web->HTTP->Hosts->Default web-module .

    Thx.