4

I have in my JSF 2 app on JBoss AS 7.1 a PrimeFaces 5.1 datatable with lazy loading and it sorts on page load, so I know my sorting implementation works, but when I click the column to sort it throws the below exception.

17:48:34,855 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/feenix].[Faces Servlet]] (http-/0:0:0:0:0:0:0:0:8080-6) JBWEB000236: Servlet.service() for servlet Faces Servlet threw exception: 
java.lang.NullPointerException
    at com.sun.faces.context.PartialViewContextImpl.createPartialResponseWriter(PartialViewContextImpl.java:469) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
    at com.sun.faces.context.PartialViewContextImpl.access$300(PartialViewContextImpl.java:76) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
    at com.sun.faces.context.PartialViewContextImpl$DelayedInitPartialResponseWriter.getWrapped(PartialViewContextImpl.java:603) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
    at javax.faces.context.PartialResponseWriter.startDocument(PartialResponseWriter.java:115) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
    at org.primefaces.context.PrimePartialResponseWriter.startDocument(PrimePartialResponseWriter.java:152) [primefaces-5.1.jar:5.1]
    at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:201) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
    at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:126) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
    at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]

My data table:

<p:dataTable var="registroD" value="#{reportes.diario}" paginator="true" rows="10" rowsPerPageTemplate="10,20,40,80" id="registroDiarioTable" lazy="true"
                                     paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}">
    <p:column headerText="Fecha">
        <h:outputText value="#{registroD.fechaRegistro}">
            <f:convertDateTime pattern="yyyy/MM/dd" type="date"/>
        </h:outputText>
    </p:column>
    <p:column headerText="Nombre Asesor" sortBy="#{registroD.idTrabajo.idUsuario.nombres}" filterBy="#{registroD.idTrabajo.idUsuario.nombres}">
        <h:outputText value="#{registroD.idTrabajo.idUsuario.nombres}"/>
    </p:column>
    <p:column headerText="Apellido Asesor" sortBy="#{registroD.idTrabajo.idUsuario.apellidos}" filterBy="#{registroD.idTrabajo.idUsuario.apellidos}">
        <h:outputText value="#{registroD.idTrabajo.idUsuario.apellidos}"/>
    </p:column>
    <p:column headerText="Lugar entrega" sortBy="#{registroD.idTrabajo.idUbicacion.direccion}" filterBy="#{registroD.idTrabajo.idUbicacion.direccion}">
        <h:outputText value="#{registroD.idTrabajo.idUbicacion.direccion}"/>
    </p:column>
    <p:column headerText="Hora entrega">
        <h:outputText value="#{registroD.fechaRegistro}">
            <f:convertDateTime pattern="HH:mm:ss" type="time"/>
        </h:outputText>
    </p:column>
    <p:column headerText="Nombre" sortBy="#{registroD.numero.nombres}" filterBy="#{registroD.numero.nombres}">
        <h:outputText value="#{registroD.numero.nombres}"/>
    </p:column>
    <p:column headerText="Apellido" sortBy="#{registroD.numero.apellidos}" filterBy="#{registroD.numero.apellidos}">
        <h:outputText value="#{registroD.numero.nombres}"/>
    </p:column>
    <p:column headerText="Numero Celular" sortBy="#{registroD.numero.numero}" filterBy="#{registroD.numero.numero}">
        <h:outputText value="#{registroD.numero.numero}" />
    </p:column>
    <p:column headerText="Producto" sortBy="#{registroD.producto}" filterBy="#{registroD.producto}">
        <h:outputText value="#{registroD.producto}"/>
    </p:column>
</p:dataTable>

This error has nothing to do (seems to me that way) with the actions I do.

What is going on?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Alvin Baena
  • 903
  • 1
  • 10
  • 24
  • The stack trace tells that an exception occurred while handling an exception during restore view phase of an ajax request. This is a second problem which has unfortunately hidden away all detail about the underlying exception which JSF was trying to handle, so this question can't be answered by just looking at the stack trace until you fix/replace the standard exception handler. Use this one and update your question with the stack trace of the real exception: http://stackoverflow.com/a/27532827/157882 – BalusC Mar 17 '15 at 07:02
  • Thank you BalusC that was the break I needed to solve my problem. Turns out I had the xhtml files in the wrong place (FileNotFoundException). You can post the previous comment as an answer and I'll accept it. – Alvin Baena Mar 17 '15 at 13:31
  • same problem here. Have you found any solution ? – Jean Dec 11 '17 at 15:24
  • Yes, I followed the answer given by BalusC. The info from the SO link helped me uncover the real exception, which was a FileNotFoundException. – Alvin Baena Dec 11 '17 at 20:18

1 Answers1

3

The stack trace tells that this exception occurred while handling an exception during restore view phase of an ajax request. This is a second problem which has unfortunately hidden away all detail about the underlying exception which JSF was trying to handle, so this question can't be answered by just looking at the stack trace until you fix/replace the standard exception handler.

If upgrading to latest Mojarra version doesn't solve it, then you can (temporarily) use the one shown in this answer to print the stack trace of the real underlying exception: Exception handling in JSF ajax requests. That should in turn give sufficient clues about the real underlying problem.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555