You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "Thomas Andraschko (JIRA)" <ji...@apache.org> on 2014/03/23 23:26:42 UTC

[jira] [Resolved] (DELTASPIKE-545) DeltaSpikeExceptionHandler getRootCause assumes caught FacesException is wrapping another Exception

     [ https://issues.apache.org/jira/browse/DELTASPIKE-545?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thomas Andraschko resolved DELTASPIKE-545.
------------------------------------------

    Resolution: Fixed

> DeltaSpikeExceptionHandler getRootCause assumes caught FacesException is wrapping another Exception
> ---------------------------------------------------------------------------------------------------
>
>                 Key: DELTASPIKE-545
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-545
>             Project: DeltaSpike
>          Issue Type: Bug
>          Components: JSF-Module
>    Affects Versions: 0.6
>         Environment: Myfaces 2.2.1 Tomcat 7.x Deltaspike 0.6
>            Reporter: Karl Kildén
>            Assignee: Thomas Andraschko
>             Fix For: 0.7
>
>
> It may be incorrect by the underlying JSF implementation to not wrap another exception with FacesException. However errors such as detection of duplicate id's are in nature FacesExceptions and the opposite could be argued.
> Regardless it's best if DeltaspikeExceptionHandler null checks rather then assuming every FacesException wraps another Exception to ensure robustness.
> This is the code Thomas Andraschko proposed as a fix. I have verified it locally and it fixed my problem.
> In DeltaspikeExceptionHandler, override getRootCause:
>     @Override
>     public Throwable getRootCause(Throwable throwable)
>     {
>         while ((ELException.class.isInstance(throwable) || FacesException.class.isInstance(throwable))
>                 && throwable.getCause() != null)
>         {
>             throwable = throwable.getCause();
>         }
>         return throwable;
>     }
> Before local fix: 
> java.lang.IllegalArgumentException: exception must not be null
> 	org.apache.deltaspike.core.api.exception.control.event.ExceptionStackEvent.<init>(ExceptionStackEvent.java:60)
> 	org.apache.deltaspike.core.impl.exception.control.ExceptionHandlerBroadcaster.executeHandlers(ExceptionHandlerBroadcaster.java:75)
> 	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
> After:
> javax.faces.FacesException: Component with id:info not found
> 	org.apache.myfaces.renderkit.html.HtmlAjaxBehaviorRenderer.getComponentId(HtmlAjaxBehaviorRenderer.java:461)
> 	org.apache.myfaces.renderkit.html.HtmlAjaxBehaviorRenderer.build(HtmlAjaxBehaviorRenderer.java:433)
> 	org.apache.myfaces.renderkit.html.HtmlAjaxBehaviorRenderer.mapToString(HtmlAjaxBehaviorRenderer.java:405)
> 	org.apache.myfaces.renderkit.html.HtmlAjaxBehaviorRenderer.makeAjax(HtmlAjaxBehaviorRenderer.java:158)
> 	org.apache.myfaces.renderkit.html.HtmlAjaxBehaviorRenderer.getScript(HtmlAjaxBehaviorRenderer.java:102)



--
This message was sent by Atlassian JIRA
(v6.2#6252)