[RESOLVED][PF6.0] NullPointerException at ResourceUtils.java

UI Components for JSF
Post Reply
drops
Posts: 7
Joined: 24 Feb 2011, 16:37

28 Sep 2016, 13:18

Hello,

I'm using Wildfly 10 as container and Primefaces 6.0 in webapp.

I have this issue during any ajax event fired after updating large part of the view.
I'm updating datatable (dynamic columns) and it works well until I have specific update that gives quite large datatable (5 cols * 300 rows). After this any ajax event ends with:

Code: Select all

13:07:23,422 ERROR [io.undertow.request] (default task-49) UT005023: Exception handling request to /myapp/mypage.xhtml: javax.servlet.ServletException
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:671)
	at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
	at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:100)
	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
	at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
	at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
	at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
	at io.undertow.server.handlers.DisableCacheHandler.handleRequest(DisableCacheHandler.java:33)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51)
	at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
	at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
	at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:56)
	at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
	at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
	at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
	at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)
	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)
	at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
	at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
	at org.primefaces.util.ResourceUtils.getComponentResources(ResourceUtils.java:66)
	at org.primefaces.context.PrimePartialResponseWriter.startMetadataIfNecessary(PrimePartialResponseWriter.java:280)
	at org.primefaces.context.PrimePartialResponseWriter.startError(PrimePartialResponseWriter.java:107)
	at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:203)
	at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:127)
	at javax.faces.context.ExceptionHandlerWrapper.handle(ExceptionHandlerWrapper.java:100)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
	at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:123)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
	... 35 more
I guess it's memory related problem but I don't have any idea where to start, my current VM options should be enough (-Xms512m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=128m).

Thanks
Last edited by drops on 30 Sep 2016, 10:58, edited 1 time in total.

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

28 Sep 2016, 13:22

Could be because FacesContext or ViewRoot is null, which shouldn't occur in a normal view without any previous errors.
I will add a null check.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

28 Sep 2016, 13:26

STOP:
I can't help without a small sample application as PrimePartialResponseWriter already check for a not existing ViewRoot. So everything should be fine in PF.

However i can see in your stacktrace that you got a previous error somewhere. If you would fix this, it should work.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

drops
Posts: 7
Joined: 24 Feb 2011, 16:37

28 Sep 2016, 13:50

I'm updating view using a parameter from selectonemenu.
I can have multiple updates without problem - only if amount of fetched data is quite small.
When error occurs, update from DB takes about 30 secs and then view is generating next few seconds.
After that this error occurs.

How to check for null?

edit: this stacktrace is everything I got from container. Any of this errors are not specific to my app...

edit2: after applying paginator to datatable no errors are shown. So it's clearly about large view...

smokeybandit
Posts: 277
Joined: 08 Jul 2013, 17:53

28 Sep 2016, 14:08

Are you redirecting to some error page w/o a h:head tag?

drops
Posts: 7
Joined: 24 Feb 2011, 16:37

28 Sep 2016, 14:14

smokeybandit wrote:Are you redirecting to some error page w/o a h:head tag?
no, not yet. I have only redirect to /index.xhtml on viewexpired exception

Code: Select all

    <error-page>
        <exception-type>javax.faces.application.ViewExpiredException</exception-type>
        <location>/index.xhtml</location>
    </error-page>
And back to my datatable paginator:
showing 50 rows at once - works ok, no errors.
showing 100 rows - error from first post.

I can leave it with paginator, but it does not solve the issue.

drops
Posts: 7
Joined: 24 Feb 2011, 16:37

30 Sep 2016, 10:01

Ok I have working example here.

The page: test.xhtml

Code: Select all

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Test</title>
    </h:head>
    <h:body>
        <h:form>
            <!--it's a part of something bigger so this part is in outputPanel-->
            <p:outputPanel id="details">
                <h:outputText value="Size: #{backBean.size}" />
            <p:panelGrid>
                <!--btw. why it forces me to set all of this variables at p.repeat?--> 
                <p:repeat value="#{backBean.content}"
                          var="_row"
                          offset="0"
                          step="1"
                          size="#{backBean.content.size()}"
                          varStatus="_rowStatus" >
                    <p:row>
                    <p:repeat value="#{_row}" 
                              var="_cell" 
                              offset="0"
                              step="1"
                              size="#{_row.size()}"
                              varStatus="_rowStatus" >
                        <p:column>
                            <p:inplace editor="true">
                                <f:facet name="output">
                                        <h:outputText value="#{_cell.output}" />                                    
                                </f:facet>
                                <f:facet name="input">
                                    <!--in real example it will be more complex with checkboxes, selectonemenu etc-->
                                    <h:outputText value="First:" />
                                    <p:inputText value="#{_cell.something}" />
                                    <br />
                                    <h:outputText value="Second:" />
                                    <p:inputText value="#{_cell.another}" />
                                </f:facet>
                            </p:inplace>
                        </p:column>
                    </p:repeat>
                    </p:row>
                </p:repeat>
            </p:panelGrid>
            

        </p:outputPanel>
            <p:commandButton value="more" update="details" actionListener="#{backBean.weNeedMore}" />
        </h:form>
    </h:body>
</html>
Backing bean:

Code: Select all


package com.test;

import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;


@Named(value = "backBean")
@SessionScoped
public class BackBean implements Serializable {
    
    private List<List<CellContent>> content;
    private int size;

    /**
     * Creates a new instance of BackBean
     */
    public BackBean() {
    }
    
    private void build() {
        content = new ArrayList<>();
        for(int i=0;i<size;i++) {
            List<CellContent> row = new ArrayList<>();
            for(int j=0;j<size;j++) {
                CellContent cell = new CellContent();
                row.add(cell);
            }
            content.add(row);
        }    
    }
    
    @PostConstruct
    public void init() {
        size = 10;  
        
        //create first content
        build();
    }
    
    public void weNeedMore() {
        //increase until we get error after click.
        size = size + 10;
        build();
    }
    
    //plain getters & setters

    public List<List<CellContent>> getContent() {
        return content;
    }

    public void setContent(List<List<CellContent>> content) {
        this.content = content;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }
        
}

and one used class:

Code: Select all

package com.test;


public class CellContent {
    
    private String something = "";
    private String another = "";
    private String output = "click_me";

    public CellContent() {
    }
    
    //some dummy update based on inputs
    private void update() {
        if(!something.equals(""))
            output = something;
        if(!another.equals(""))
            output = "another: " + another;
    }
    
    //those two setters update the object
    public void setSomething(String something) {
        this.something = something;
        update();
    }
    
    public void setAnother(String another) {
        this.another = another;
        update();
    }

    //rest are plain get&seters
    public String getSomething() {
        return something;
    }

    public String getAnother() {
        return another;
    }

    public String getOutput() {
        return output;
    }

    public void setOutput(String output) {
        this.output = output;
    }
  
    
}
When size of grid is small, like 10x10 or event 20x20 it's working.
Just hit "more" until you get 30x30 grid and after clicking any cell error shows like this:

Code: Select all

09:47:13,602 ERROR [io.undertow.request] (default task-89) UT005023: Exception handling request to /myapp/test.xhtml: javax.servlet.ServletException
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:671)
	at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
	at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:100)
	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
	at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
	at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
	at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51)
	at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
	at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
	at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:56)
	at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
	at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
	at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
	at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
	at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)
	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)
	at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
	at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
	at org.primefaces.util.ResourceUtils.getComponentResources(ResourceUtils.java:66)
	at org.primefaces.context.PrimePartialResponseWriter.startMetadataIfNecessary(PrimePartialResponseWriter.java:280)
	at org.primefaces.context.PrimePartialResponseWriter.startError(PrimePartialResponseWriter.java:107)
	at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:203)
	at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:127)
	at javax.faces.context.ExceptionHandlerWrapper.handle(ExceptionHandlerWrapper.java:100)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
	at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:123)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
	... 34 more

It's obvoiously about too many objects on single page. Are there any parameters I could adjust? Or it's primefaces issue?

I'm running it on Wildfly 10, PF6.0.

drops
Posts: 7
Joined: 24 Feb 2011, 16:37

30 Sep 2016, 10:55

I've found it.

After switching back to PF5.3, there was no p:repeat so I took ui:repeat instead.
That gave me an answer:

Code: Select all

10:37:58,508 SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (default task-44) java.lang.IllegalStateException: UT000047: The number of parameters exceeded the maximum of 1000
All I need is to increase max-parameters in standalone-full.xml and IT WORKS!

hcbarretos
Posts: 4
Joined: 06 Jun 2017, 16:42

05 Jul 2018, 16:53

I've had a similar problem.

The error was not caused by PF 6.0 but the upgrade to version 6.1 gave me a different message.

The problem was caused by Undertow - the web server component of Wildfly.

MAX_PARAMETERS
The maximum number of query parameters that are permitted in a request. If a client sends more than this number the connection will be closed. This limit is necessary to protect against hash based denial of service attacks. Defaults to 1000.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 40 guests