Custom error page

If an exception is thrown, it will be redirected to an error page where the stack trace etc. is shown. I want for this case a custom error page.

For the custom error page I created a new class (which extends UI) and a VaadinServlet:

@WebServlet(urlPatterns = { “/exception/*” }, name = “SignMeExceptionServlet”, asyncSupported = true)
@VaadinServletConfiguration(ui = ExceptionUI.class, productionMode = false)
public static class SignMeExceptionServlet
extends VaadinServlet
private static final long serialVersionUID = 1L;

I tried to add this to the web.xml:


But the problem is that the exception.html site will be loaded, but it’s not a html page, it’s a vaadin ui…

How can I do this??

If the exception occurs
the Vaadin UI has been loaded, then Vaadin will show the exception in a
(given, that productionMode is false) or then Vaadin will show an error notification.

In case the exception occurs
the UI has been loaded, then it is your servlet container that manages the exception and it will show an HTML page containing the stack trace. To modify this page, you need to configure your servlet container. How you do this is dependent on which servlet container/applicaiton server you are using.

If you have
custom exception handling
in your Vaadin application and you
manually forward
the user to an error page, then you need to serve the HTML page through another servlet than a Vaadin servlet (default servlet should be OK). See web.xml/application server documentation for more details.

I have the case when the exception occurs before the UI has been loaded and I’m using tomcat 7… So is it possible to show then a vaadin ui page?

Well, you see the error page because there was an exception that hindered loading the UI, so you can’t really show the UI unless you know that there won’t be an exception the next time (or you’ll end up in an endless loop). Even in that case, you’d probably need to do some sort of a redirect from the error page (I’m not that familiar with application server configuring, so not sure).

Unless there is no exception on the error page, how can I do this then?

Or how can i specify the location of the error page in the web.xml so that the vaadin page will be loaded without the .html ending.

Solved this problem by creating a jsp file. I just created vaadin components shown in a page in the browser and copied the html code from firebug. So the jsp file can be defined in the web.xml as the error page.
Then to show specific data, I saved them into the session (within VaadinSession.getWrappedSession) before an error occurs.

Hello and in case it extends from a VaadinCDIServlet?

Another thing, where I put the jspFile