dev@javaserverfaces.java.net

Re: NPE with RI and Facelets ui:debug component

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Wed, 02 Aug 2006 11:38:16 -0700

UIViewRoot.getRenderKitId() states:

/**
     * <p>Return the render kit identifier of the {_at_link RenderKit}
     * associated with this view. Unless explicitly set, as in {_at_link
     * javax.faces.application.ViewHandler#createView}, the returned
     * value will be <code>null.</code></p>
     */

Also, ViewHandler.createView() requires the view handler to populate
the RenderKit ID. So it seems that this is an issue with the
FaceletsViewHandler.

Also, it seems that FacesContextImpl.getRenderKit() isn't implemented
properly. If there is no renderkit ID, this method should return null.
I've logged an issue [1] to correct this.

[1] https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=384

Michael Youngstrom wrote:
> So what's the word on this? Should the UIViewRoot return the default
> renderkit if one cannot be found instead of the default view handler
> specifying the default if UIViewRoot returns null from
> getRenderKitId()?
>
> On 8/1/06, Michael Youngstrom <youngm_at_gmail.com> wrote:
>> ui:debug throws an NPE when used with jsf 1.2_01. What it appears is
>> happening is the FaceletsViewHandler on create and restoreView checks
>> to see if the request is a debug request. If it is then facelets
>> instantiates a new UIViewRoot instead of deferring creation to the
>> parent. The problem is that facelets does not set the renderkit on
>> the newly created ViewRoot so a NPE is thrown because the
>> FacesContext.getRenderKit() assumes that because there will be a
>> renderkit set if there is a ViewRoot.
>>
>> It is probably undesirable behaviour for the RI to throw a NPE if the
>> renderkit is null but should the UIViewRoot be providing a default
>> renderkit? Or should Facelets be setting the renderkit when it
>> creates the UIViewRoot and the RI check for a null renderkit and throw
>> a more appropriate exception?
>>
>> Mike
>>
>>
>> java.lang.NullPointerException
>> at
>> com.sun.faces.context.FacesContextImpl.getRenderKit(FacesContextImpl.java:276)
>>
>> at
>> com.sun.faces.renderkit.RenderKitUtils.getResponseStateManager(RenderKitUtils.java:235)
>>
>> at
>> com.sun.faces.lifecycle.LifecycleImpl.reload(LifecycleImpl.java:327)
>> at
>> com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:115)
>> at
>> javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
>> at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
>>
>> at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>>
>> at
>> org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
>>
>> at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
>>
>> at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>>
>> at
>> org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
>>
>> at
>> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
>>
>> at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
>>
>> at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>>
>> at
>> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:264)
>>
>> at
>> org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
>>
>> at
>> org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
>>
>> at
>> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
>>
>> at
>> org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110)
>>
>> at
>> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
>>
>> at
>> org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
>>
>> at
>> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
>>
>> at
>> org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81)
>>
>> at
>> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
>>
>> at
>> org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:217)
>>
>> at
>> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
>>
>> at
>> org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java:108)
>> at
>> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
>>
>> at
>> org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:191)
>>
>> at
>> org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
>>
>> at
>> org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:148)
>>
>> at
>> org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:90)
>>
>> at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
>>
>> at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>>
>> at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
>>
>> at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
>>
>> at
>> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
>>
>> at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
>>
>> at
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
>>
>> at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
>>
>> at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
>>
>> at
>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
>>
>> at
>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
>>
>> at
>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
>>
>> at
>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
>>
>> at
>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
>>
>> at java.lang.Thread.run(Thread.java:595)
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
>