[undertow-dev] Undertow forwards too early when handling error page, causing many issues

arjan tijms arjan.tijms at gmail.com
Wed Oct 1 05:45:52 EDT 2014


Hi,

Contrary to other servers (Tomcat, JBoss AS 7/EAP 6, GlassFish and
probably all others), Undertow immediately performs a forward when
HttpServletResponse#sendError() is invoked instead of waiting until
all servlets and filters of the application are finished.

In case the error page happens to be a Facelets page, this forward
causes the FacesServlet to be invoked once again, basically creating
another FacesContext inside the same thread. This overrides the
previous FacesContext. After that is released, the "original"
FacesContext is never put back.

In OmniFaces we created a workaround for this, see
https://github.com/omnifaces/omnifaces/commit/b9badb86cb2112fd87485e060db21262de58887c

Unfortunately, this OmniFaces workaround isn't bulletproof. In case of
an HTTP 400, PrimeFaces loses its RequestContext as well and OmniFaces
can't help setting it back.

This results in exceptions like the following:

java.lang.NullPointerException
        at org.primefaces.context.PrimeFacesContext.release(PrimeFacesContext.java:26)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:665)

Although not confirmed, this behaviour from Undertow is the likely
cause of a large number of other exceptions as well.

Kind regards,
Arjan Tijms


More information about the undertow-dev mailing list