Application specific error pages

Hi,

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!

Regards,
Kurt

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

[code]
@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.

[code]
@Theme(“mytheme”)
public class MyUI extends UI {

@Override
protected void init(VaadinRequest vaadinRequest) {
    VerticalLayout layout = new VerticalLayout();        
    layout.setMargin(true);
    layout.setSpacing(true);
    setContent(layout);
    
    TextField name = new TextField();
    name.setCaption("The application has started");
    layout.addComponents(name);
    
    throw new MissingResourceException("Wepaaaaah",
                                        MyUI.class.getSimpleName(),
                                        "test");
}

}
[/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]



30

<error-page>
    <error-code>500</error-code>
    <location>/error/500.html</location>
</error-page>
[/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.
29216.png
29217.png