Application specific error pages


After doing some research, I found out how to enable custom error pages at WAR level. I have created a sample app to test things a bit (sources bellow). In the configuration changes I have made, everything seems to work as desired except at one point. The look and feel of the custom error page seems to be overruled by Vaadin theming. I suppose this is caused by the fact the exception is thrown from within the init-method.

The question is, how can I overrule the Vaadin theme from being applied when a custom error page needs to be displayed to the user. Thank you for reading my question!


Bellow you will find the different sources of the sample application and the corresponding configuration changes.
First the VaadinServlet class is defined as bellow.

@WebServlet(urlPatterns = {“/ui/", "/VAADIN/”},
name = “MyUIServlet”,
asyncSupported = true)
@VaadinServletConfiguration(ui = MyUI.class,
productionMode = false)
public class MyUIServlet extends VaadinServlet{

[/code]The corresponding UI class does the following.

public class MyUI extends UI {

protected void init(VaadinRequest vaadinRequest) {
    VerticalLayout layout = new VerticalLayout();        
    TextField name = new TextField();
    name.setCaption("The application has started");
    throw new MissingResourceException("Wepaaaaah",

[/code]In actual code the MissingResourceException would e.g. be thrown when a JNDI look-up fails. Since this is considered an irrecoverable error, a custom error page might be usefull for the user, together with some server-side logging.

To enable the custom error page, the following web.xml has been added to the WAR.



[/code]Finally, the custom error page [code] HTTP 500 Error
Woops something went wrong
[/code] When the WAR is deployed (Glassfish 4.1) the 'displayed' (see attachments) is shown while the expected layout should be expected.png. Clearly, some layout styles are overruled...

The attachments mentionned in previous post.