NullPointerException in PickListRenderer after validation failure

UI Components for JSF
Post Reply
matinh
Posts: 20
Joined: 11 Nov 2013, 16:04

22 Feb 2019, 14:06

Hi!

I get a NullPointerException in PickListRenderer after a validation failure triggered by OmniFaces' <o:validateAll> component:

Code: Select all

Caused by:java.lang.NullPointerException
    at org.primefaces.component.picklist.PickListRenderer.encodeMarkup(PickListRenderer.java:92)
    at org.primefaces.component.picklist.PickListRenderer.encodeEnd(PickListRenderer.java:59)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
    at org.omnifaces.viewhandler.OmniViewHandler.renderView(OmniViewHandler.java:119)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
    [...]
I currently don't know if this is a problem with PrimeFaces or OmniFaces. I've created a question on StackOverflow with all details and example code.

Has anybody some idea?

Many thanks,
- martin
--
PrimeFaces 6.2 on Wildfly 10 with Mojarra 2.2.15.

matinh
Posts: 20
Joined: 11 Nov 2013, 16:04

24 Apr 2019, 14:46

This problem still exists with PrimeFaces 7.0.
It even got worse (another NPE) due to commits regarding issue #2127.
I also updated the corresponding question on StackOverflow.

Anybody any idea?

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

25 Apr 2019, 13:01

Can you please post your new Stack Trace. Definitely probably needs some NULL checks in the code.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

matinh
Posts: 20
Joined: 11 Nov 2013, 16:04

25 Apr 2019, 13:14

Hi!

And thanks for looking into it.
The StackTrace is on the mentioned StackOverflow page. With PrimeFaces 7.0 it's this:

Code: Select all

Caused by:java.lang.NullPointerException
    at org.primefaces.component.picklist.PickList.validateValue(PickList.java:140)
    at javax.faces.component.UIInput.validate(UIInput.java:982)
    at org.primefaces.component.picklist.PickList.validate(PickList.java:181)
    at javax.faces.component.UIInput.executeValidate(UIInput.java:1248)
    at javax.faces.component.UIInput.processValidators(UIInput.java:712)
    at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:575)
    at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1689)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
    at javax.faces.component.UIForm.visitTree(UIForm.java:371)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
    at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:403)
    at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:266)
    at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:63)
    at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:219)
    at org.omnifaces.context.OmniPartialViewContext.processPartial(OmniPartialViewContext.java:124)
    at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1193)
    at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
   
And for the PickListRenderer the NPE is in line 127:

Code: Select all

        encodeList(context, pickList, clientId + "_target", PickList.TARGET_CLASS, model.getTarget(),
                pickList.getFacet("targetCaption"), pickList.isShowTargetFilter(), false);
hth,
- martin

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

25 Apr 2019, 13:42

Thanks since you seems to have really dug into this issue it seems a lot around the old Model being empty? If you have any suggested fixes to PickList I can definitely submit a PR.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

matinh
Posts: 20
Joined: 11 Nov 2013, 16:04

25 Apr 2019, 13:55

Yes, the old model is null, and that's exactly the same cause for the NPE in the PickList class. Unfortunately I couldn't find out why or how they got null. In the debugger I had the expected values for the model and somewhen they just disappeared. Breakpoints in the setter didn't get hit. However, I have to admit, that I'm not that confident with JSF component development and especially state management is not always completely clear to me.

Anyways, a null-check around PickList line 140 and PickListRenderer around 127 would definitively help.

- martin

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

25 Apr 2019, 15:08

PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 10 guests