3.5 regression: NPE in case of exception during ajax request

UI Components for JSF
Post Reply
nicolas
Posts: 3
Joined: 07 Dec 2010, 11:40

08 Feb 2013, 02:24

Hello,

I am experiencing an NPE after upgrading from 3.4.2 to 3.5
I am using omnifaces 1.3 & mojarra 2.1.17
It happens when an exception is thrown during an ajax request.
As a consequence the error page cannot be displayed
It works perfectly with PF 3.4.2 (no npe and error page displayed properly)
Here is the stack trace... anyone experiencing it too?

Nicolas


java.lang.NullPointerException
at org.primefaces.renderkit.CoreRenderer.getWidgetBuilder(CoreRenderer.java:481)
at org.primefaces.component.layout.LayoutRenderer.encodeScript(LayoutRenderer.java:65)
at org.primefaces.component.layout.LayoutRenderer.encodeBegin(LayoutRenderer.java:41)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:820)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1777)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at com.sun.faces.context.PartialViewContextImpl.renderAll(PartialViewContextImpl.java:404)
at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:289)
at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:183)
at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:183)
at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:982)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:411)
at org.omnifaces.exceptionhandler.FullAjaxExceptionHandler.renderErrorPageView(FullAjaxExceptionHandler.java:231)
at org.omnifaces.exceptionhandler.FullAjaxExceptionHandler.handleAjaxException(FullAjaxExceptionHandler.java:200)
at org.omnifaces.exceptionhandler.FullAjaxExceptionHandler.handle(FullAjaxExceptionHandler.java:145)

hosarb
Posts: 3
Joined: 09 Feb 2013, 07:16

09 Feb 2013, 07:28

Hi
I have the same problem, I cant say the exact problem, but in many of my pages the problem happens

Code: Select all

java.lang.NullPointerException
	at org.primefaces.renderkit.CoreRenderer.getWidgetBuilder(CoreRenderer.java:481)
	at org.primefaces.component.ajaxstatus.AjaxStatusRenderer.encodeScript(AjaxStatusRenderer.java:41)
	at org.primefaces.component.ajaxstatus.AjaxStatusRenderer.encodeEnd(AjaxStatusRenderer.java:34)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:665)
	at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:545)
	at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:541)
	at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:541)
	at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1981)
	at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:285)
	at org.springframework.faces.webflow.FlowViewHandler.renderView(FlowViewHandler.java:99)
	at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:116)
	at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
	at org.springframework.faces.webflow.FlowLifecycle.render(FlowLifecycle.java:80)
	at org.springframework.faces.webflow.JsfView.render(JsfView.java:89)
	at org.springframework.webflow.engine.ViewState.render(ViewState.java:296)
	at org.springframework.webflow.engine.ViewState.refresh(ViewState.java:243)
	at org.springframework.webflow.engine.ViewState.resume(ViewState.java:221)
	at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
	at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:258)
	at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
	at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
	at org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:48)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.access.channel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:144)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)


I've tried removing the AjaxStatus, but the exception keeps repeating itself for another component.
Basically the problem is the "primefaces.REQUEST_CONTEXT" dose not exists in the FacesContext attributes.
But how and when it must be defined I have no idea.

hosarb
Posts: 3
Joined: 09 Feb 2013, 07:16

09 Feb 2013, 08:03

Hi again.
I've solved the problrm for now, inspired by http://code.google.com/p/omnifaces/issues/detail?id=130

I've added this to my pages :

Code: Select all

<f:metadata>
   <f:event listener="#{primefacesUtilBean.initalizeContext}" type="preRenderView" />
</f:metadata>
and the implementation of the managed bean is like this :

Code: Select all

@ManagedBean
public class PrimefacesUtilBean implements Serializable {

  private static final long serialVersionUID = 7065489285667343028L;

  private static final Logger logger = LoggerFactory.getLogger(PrimefacesUtilBean.class);

  /**
   * Initialize Primefaces context.
   */
  public void initalizeContext() {
    FacesContext context = FacesContext.getCurrentInstance();
    RequestContext requestContext = ((RequestContext) context.getAttributes().get(Constants.REQUEST_CONTEXT_ATTR));
    if (requestContext == null) {
      context.getAttributes().put(Constants.REQUEST_CONTEXT_ATTR, new DefaultRequestContext());
      logger.debug("Primefaces request context was null so it has been initialized.");
    }
  }
}
that solved the problem for now. and in my testes nothing wrong happens. but I'm looking forward to here any better solution.

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

09 Feb 2013, 08:37

Can you share your xhtml that caused the error? maybe 2 or 3 of your xhtml that caused this issue?

I don't see this issue at all, and I'm using OmniFaces 1.3 'and' PrimeFaces 3.5, and I used PrimeFaces 3.5-SNAPSHOT and OmniFaces 1.3 (snapshot) ever since 'both' released 'snapshot' versions.

I'm sure i'm not doing something that you're doing.

Are you using PrimeFaces requestContext 'and' using OmniFaces? Does the error occur when you eliminate/remove OmniFaces?

I ask, because I do 'not' use PrimeFaces requestContext. I use OmniFaces Ajax utility, which is similar to requestContext.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

DeezCashews
Posts: 1
Joined: 20 Feb 2013, 23:45

20 Feb 2013, 23:50

I am noticing the same behavior when trying to call a subflow. When I downgrade to 3.4.2 the error goes away. In my case it is happening when a <p:menubar> is rendering. I'm not sure yet if it has to do with the subflow call or the fact that the <p:menubar> is in a template for the page. Thought I might post to see if anyone else is getting this with just Prime 3.5 and JSF 2.1.17.

MTornros
Posts: 102
Joined: 23 Dec 2011, 16:43

21 Feb 2013, 12:33

I'm having the same problem when trying to enter subflows (spring webflow).

Code: Select all

java.lang.NullPointerException
	at org.primefaces.renderkit.CoreRenderer.getWidgetBuilder(CoreRenderer.java:481)
	at org.primefaces.component.menubutton.MenuButtonRenderer.encodeScript(MenuButtonRenderer.java:136)
	at org.primefaces.component.menu.BaseMenuRenderer.encodeEnd(BaseMenuRenderer.java:40)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
and so on...

Removing the menubutton from the page just causes the error to appear in some other renderer.

EDIT: Changing CoreRenderer.java as suggested here fixed the issue: http://code.google.com/p/primefaces/iss ... il?id=5141
Primefaces 3.4.1-jQueryfix
Spring webflow 2.3.1
Mojarra jsf 2.1.7

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 51 guests