On WildFly 8-1 I have primefaces-5.1.jar
and primefaces-extensions-2.1.0.jar
in my webapps WEB-INF/lib
directory.
I have configured WEB-INF/faces-config.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
version="2.2">
<application>
<el-resolver>org.primefaces.application.exceptionhandler.PrimeExceptionHandlerELResolver</el-resolver>
</application>
<factory>
<exception-handler-factory>org.primefaces.application.exceptionhandler.PrimeExceptionHandlerFactory</exception-handler-factory>
</factory>
</faces-config>
I have the following JSF.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions">
<h:head></h:head>
<h:body>
<h:form id="form">
<pe:ajaxErrorHandler body="ERROR"/>
<p:commandButton actionListener="#{dossierResumen.excepcion}" value="Excepción"/>
</h:form>
</h:body>
</html>
where DossierResumen#excepcion()
is
public void excepcion() {
throw new NullPointerException("EXCEPCION! EXCEPCION!");
}
When I click the button, I get no popups at all; the page gets redirected to the URL for error 500 defined in web.xml
. In the logs, I get the following wall of stacktrace:
What am I doing wrong?
15:44:14,206 ERROR [stderr] (default task-42) java.lang.NullPointerException: EXCEPCION! EXCEPCION! 15:44:14,206 ERROR [stderr] (default task-42) at es.imasmallorca.selene.webone.jsf.controller.dossier.DossierResumen.excepcion(DossierResumen.java:55) 15:44:14,206 ERROR [stderr] (default task-42) at es.imasmallorca.selene.webone.jsf.controller.dossier.DossierResumen$Proxy$_$$WeldClientProxy.excepcion(Unknown Source) 15:44:14,206 ERROR [stderr] (default task-42) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 15:44:14,206 ERROR [stderr] (default task-42) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 15:44:14,207 ERROR [stderr] (default task-42) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 15:44:14,207 ERROR [stderr] (default task-42) at java.lang.reflect.Method.invoke(Method.java:606) 15:44:14,207 ERROR [stderr] (default task-42) at com.sun.el.parser.AstValue.invoke(AstValue.java:275) 15:44:14,207 ERROR [stderr] (default task-42) at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304) 15:44:14,207 ERROR [stderr] (default task-42) at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) 15:44:14,207 ERROR [stderr] (default task-42) at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) 15:44:14,208 ERROR [stderr] (default task-42) at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) 15:44:14,208 ERROR [stderr] (default task-42) at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) 15:44:14,208 ERROR [stderr] (default task-42) at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:149) 15:44:14,208 ERROR [stderr] (default task-42) at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88) 15:44:14,208 ERROR [stderr] (default task-42) at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:813) 15:44:14,208 ERROR [stderr] (default task-42) at javax.faces.component.UICommand.broadcast(UICommand.java:300) 15:44:14,209 ERROR [stderr] (default task-42) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790) 15:44:14,209 ERROR [stderr] (default task-42) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282) 15:44:14,209 ERROR [stderr] (default task-42) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) 15:44:14,209 ERROR [stderr] (default task-42) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) 15:44:14,209 ERROR [stderr] (default task-42) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198) 15:44:14,209 ERROR [stderr] (default task-42) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646) 15:44:14,210 ERROR [stderr] (default task-42) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) 15:44:14,210 ERROR [stderr] (default task-42) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) 15:44:14,210 ERROR [stderr] (default task-42) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) 15:44:14,210 ERROR [stderr] (default task-42) at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) 15:44:14,210 ERROR [stderr] (default task-42) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) 15:44:14,210 ERROR [stderr] (default task-42) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113) 15:44:14,211 ERROR [stderr] (default task-42) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) 15:44:14,211 ERROR [stderr] (default task-42) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) 15:44:14,211 ERROR [stderr] (default task-42) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) 15:44:14,211 ERROR [stderr] (default task-42) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61) 15:44:14,211 ERROR [stderr] (default task-42) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) 15:44:14,212 ERROR [stderr] (default task-42) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) 15:44:14,212 ERROR [stderr] (default task-42) at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) 15:44:14,212 ERROR [stderr] (default task-42) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) 15:44:14,212 ERROR [stderr] (default task-42) at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) 15:44:14,212 ERROR [stderr] (default task-42) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) 15:44:14,212 ERROR [stderr] (default task-42) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) 15:44:14,213 ERROR [stderr] (default task-42) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240) 15:44:14,213 ERROR [stderr] (default task-42) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227) 15:44:14,213 ERROR [stderr] (default task-42) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73) 15:44:14,213 ERROR [stderr] (default task-42) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146) 15:44:14,213 ERROR [stderr] (default task-42) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177) 15:44:14,213 ERROR [stderr] (default task-42) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727) 15:44:14,214 ERROR [stderr] (default task-42) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 15:44:14,214 ERROR [stderr] (default task-42) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 15:44:14,214 ERROR [stderr] (default task-42) at java.lang.Thread.run(Thread.java:745) 15:44:14,214 SEVERE [org.primefaces.application.exceptionhandler.PrimeExceptionHandler] (default task-42) EXCEPCION! EXCEPCION!: java.lang.NullPointerException: EXCEPCION! EXCEPCION! at es.imasmallorca.selene.webone.jsf.controller.dossier.DossierResumen.excepcion(DossierResumen.java:55) [classes:] at es.imasmallorca.selene.webone.jsf.controller.dossier.DossierResumen$Proxy$$$_WeldClientProxy.excepcion(Unknown Source) [classes:] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_55] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_55] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_55] at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_55] at com.sun.el.parser.AstValue.invoke(AstValue.java:275) [javax.el-3.0.0.jar:] at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304) [javax.el-3.0.0.jar:] at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23] at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23] at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23] at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23] at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:149) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6] at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6] at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:813) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6] at javax.faces.component.UICommand.broadcast(UICommand.java:300) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6] at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6] at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6] at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.2.6-jbossorg-4.jar:] at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.2.6-jbossorg-4.jar:] at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198) [jsf-impl-2.2.6-jbossorg-4.jar:] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6] at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final] at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final] at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.0.15.Final.jar:1.0.15.Final] at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.0.15.Final.jar:1.0.15.Final] at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.0.15.Final.jar:1.0.15.Final] at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final] at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final] at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final] at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final] at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177) [undertow-core-1.0.15.Final.jar:1.0.15.Final] at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727) [undertow-core-1.0.15.Final.jar:1.0.15.Final] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_55] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_55] at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_55]
Update:
At Guaido79's request, my web.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>seleneWar</display-name>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<error-page>
<error-code>500</error-code>
<location>/error/500.xhtml</location>
</error-page>
<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>primefaces.CLIENT_SIDE_VALIDATION</param-name>
<param-value>true</param-value>
</context-param>
<resource-ref>
<res-ref-name>jsf/ProjectStage</res-ref-name>
<res-type>java.lang.String</res-type>
</resource-ref>
</web-app>
There are two modes in that component: simple and extended mode.
In the simple mode, you don't need to specify anything in your faces-config.xml
. So you can delete these lines:
<application>
<el-resolver>org.primefaces.application.exceptionhandler.PrimeExceptionHandlerELResolver</el-resolver>
</application>
<factory>
<exception-handler-factory>org.primefaces.application.exceptionhandler.PrimeExceptionHandlerFactory</exception-handler-factory>
</factory>
Or delete the whole faces-config.xml
file since it's the only thing you have in there. Then you can test simple mode, which is working fine without defining anything else in your web.xml. This might be enough for your needs.
From the error trace, it seems that in extended mode (with that faces-config.xml
configuration), the component needs to have an error page defined in your web.xml
. You don't want a redirection to an error page, so if you add the following code to your web.xml
for example works, but not for your needs:
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/error/500.xhtml</location>
</error-page>
Anyway, it's HIGHLY recommended to use the p:ajaxExceptionHandler
native component since it looks like the authors of PrimeFaces Extensions will probably remove the component in the future since it's no longer necessary (link) already removed the component in version 3.2.0. (link)