Seam does'nt catch exception
goschan Dec 9, 2011 9:05 AMHello
I try to handle exception in my project.
In my components.xml :
<core:init jndi-pattern="OrderForm-0.0.1-SNAPSHOT/#{ejbName}/local" debug="false"/>
In web.xml :
<filter-mapping> <filter-name>Seam Filter</filter-name> <url-pattern>*.xhtml</url-pattern> <servlet-name>Faces Servlet</servlet-name> <dispatcher>FORWARD</dispatcher> <dispatcher>REQUEST</dispatcher> <dispatcher>INCLUDE</dispatcher> </filter-mapping> <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.xhtml</param-value> </context-param> <context-param> <param-name>facelets.DEVELOPMENT</param-name> <param-value>false</param-value> </context-param> ' In my OrderformHome.java : ' public void checkOrderLineWarning() throws OrderformException { if (getInstance().getOrderLineOrderforms() == null || getInstance().getOrderLineOrderforms().size() < 1) { //throw new OrderformException(Utils.getMessageBundle("validate_orderline_atleast"), null); throw new RuntimeException("simulate runtime exception"); } }
My OrderformException.java :
@ApplicationException(rollback=true) @Redirect(viewId = "/error.xhtml") public class OrderformException extends Exception{ public OrderformException() {} }
pages.xml :
[...] <exception class="java.lang.RuntimeException"> <redirect view-id="/error.xhtml"> <message>Unexpected failure</message> </redirect> </exception> <exception> <redirect view-id="/error.xhtml"> <message severity="error">Unexpected error, please try again</message> </redirect> </exception> </pages>
And whatever if I throw OrderformException or RuntimeException, all I have is a trace in the console (my application freeze, no ajax call would work :
13:57:17,960 SEVERE [application] java.lang.RuntimeException: simulate runtime exception javax.faces.el.EvaluationException: java.lang.RuntimeException: simulate runtime exception at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102) at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) at javax.faces.component.UICommand.broadcast(UICommand.java:387) at org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:55) at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:324) at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:299) at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:256) at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:469) [...] Caused by: java.lang.RuntimeException: simulate runtime exception at com.orderform.session.OrderformHome.checkOrderLineWarning(OrderformHome.java:1494) at com.orderform.session.OrderformHome.calOrderLine(OrderformHome.java:883) at com.orderform.session.OrderformHome.removeOrderLine(OrderformHome.java:920) [...] 13:57:17,964 ERROR [LifecyclePhase] Error executing INVOKE_APPLICATION 5 phase. javax.faces.FacesException: #{orderformHome.removeOrderLine}: java.lang.RuntimeException: simulate runtime exception at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118) at javax.faces.component.UICommand.broadcast(UICommand.java:387) at org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:55) at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:324) at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:299) at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:256) at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:469) at org.jboss.portletbridge.lifecycle.InvokeApplicationPhase.executePhase(InvokeApplicationPhase.java:57) at org.jboss.portletbridge.lifecycle.LifecyclePhase.execute(LifecyclePhase.java:72) at org.jboss.portletbridge.lifecycle.UpdateModelPhase.executeNextPhase(UpdateModelPhase.java:49) at org.jboss.portletbridge.lifecycle.LifecyclePhase.execute(LifecyclePhase.java:99) at org.jboss.portletbridge.lifecycle.ProcessValidatorsPhase.executeNextPhase(ProcessValidatorsPhase.java:50) at org.jboss.portletbridge.lifecycle.LifecyclePhase.execute(LifecyclePhase.java:99)
Am I missing something ?