myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grant Smith <gr...@marathon-man.com>
Subject Re: error handling
Date Fri, 12 Nov 2004 19:43:09 GMT
+1
Grant

On Thursday 11 November 2004 09:04, Bill Dudney wrote:
> Hi All,
>
> I had a bogus renderer class name in my faces-config.xml file which was
> causing a lot of problems. However the error I was getting
>
> java.lang.IllegalStateException:
> org.apache.myfaces.webapp.webxml.WebXml.init must be called before!
>
> org.apache.myfaces.webapp.webxml.WebXml.getWebXml(WebXml.java:131)
>
> org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.getServletMap
> ping(JspTilesViewHandlerImpl.java:236)
>
> org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.renderView(Js
> pTilesViewHandlerImpl.java:130)
>
> org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:
> 290)
>          javax.faces.webapp.FacesServlet.service(FacesServlet.java:110)
>
> org.springframework.orm.hibernate.support.OpenSessionInViewFilter.doFilt
> erInternal(OpenSessionInViewFilter.java:170)
>
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequ
> estFilter.java:73)
>
> org.apache.myfaces.custom.fileupload.MultipartFilter.doFilter(MultipartF
> ilter.java:88)
>
> was not all together helpful :-)
>
> Turns out the problem was that the bogus class name was causing the
> whole loading of the configuration to fail so there was no render kit
> and a bunch of other bad things. The WebXml.init is called after the
> call to FacesConfigurator.configure so the init was not called which
> was the immediate cause of the error. However after much banging my
> head against the monitor I was getting null renderkits and lots of
> other bad things.
>
> So I propose the following patch to FacesConfigurator to give a better
> warning and to allow the configuration to proceed.
>
> Your thoughts are greatly appreciated.
>
> If there is no objection I'll commit this code.
>
> TTFN,
>
> -bd-
>
> Index: FacesConfigurator.java
> ===================================================================
> RCS file:
> /home/cvs/incubator-myfaces/src/myfaces/org/apache/myfaces/config/
> FacesConfigurator.java,v
> retrieving revision 1.7
> diff -u -r1.7 FacesConfigurator.java
> --- FacesConfigurator.java	13 Oct 2004 11:50:59 -0000	1.7
> +++ FacesConfigurator.java	11 Nov 2004 17:02:10 -0000
> @@ -607,7 +607,14 @@
>               for (Iterator renderers =
> _dispenser.getRenderers(renderKitId); renderers.hasNext();)
>               {
>                   Renderer element = (Renderer) renderers.next();
> -                javax.faces.render.Renderer renderer =
> (javax.faces.render.Renderer)
> ClassUtils.newInstance(element.getRendererClass());
> +                javax.faces.render.Renderer renderer = null;
> +                try {
> +                  renderer = (javax.faces.render.Renderer)
> ClassUtils.newInstance(element.getRendererClass());
> +                } catch(FacesException e) {
> +                  // ignore the failure so that the render kit is
> configured
> +                  log.error("failed to configure class " +
> element.getRendererClass(), e);
> +                  continue;
> +                }
>
>                   renderKit.addRenderer(element.getComponentFamily(),
> element.getRendererType(), renderer);
>               }

Mime
View raw message