NPE in Table

I am using Vaadin 6.5.0 and encountered a problem. What could possibly lead to following exception:

SEVERE: Terminal error:
java.lang.NullPointerException
        at com.vaadin.ui.Table.paintContent(Table.java:2317)
        at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:754)
        at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.writeUidlResponce(AbstractCommunicationManager.java:949)
        at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.paintAfterVariableChanges(AbstractCommunicationManager.java:836)
        at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:762)
        at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:296)
        at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:483)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:662)

What most surprises me is the fact that none of my classes is mentioned in the stack trace above. Also the line which is causing problem should never cause a NPE - that would mean that first of the rendered columns is null inside the Table implementation…

Putting it simple - I’m stuck, any help would be appreciated.

Hi,

That’s really odd. The line in question is
“total–;”
, where total is an int, so the NPE is strange. Are you able to reproduce this exception in a small test application or does it only happen in your application? If you can find a way to reproduce it we can debug it.

Have you tried updating to 6.5.1 and see if that has any effect?

/Jonatan

Hello and thank you for reply.

The problem occurs on a semi-production environment and inside a quite large application. I couldn’t reproduce it locally and updating to 6.5.1 there would require some work.

In Vaadin 6.5.0 the line in question looked like:

        int rows;
        if (reqRowsToPaint >= 0) {
            rows = reqRowsToPaint;
        } else {
2317:       rows = cells[0]
.length;
            if (alwaysRecalculateColumnWidths) {
                // TODO experimental feature for now: tell the client to
                // recalculate column widths.
                // We'll only do this for paints that do not originate from
                // table scroll/cache requests (i.e when reqRowsToPaint<0)
                target.addAttribute("recalcWidths", true);
            }
        }

        if (!isNullSelectionAllowed() && getNullSelectionItemId() != null
                && containsId(getNullSelectionItemId())) {
            total--;
            rows--;
        }

This is probably related/similar to the issue
#5756
where getVisibleItemIds() is called before the table is rendered for the first time, but what triggers the problem in your case is not clear to me. What operations are you performing on the table after it has been displayed (adding/removing columns, modifying alignments, changing the data source, …)?

As for the line numbers not matching up between SVN and the packaged classes, the packaged files have a small license header that causes a fixed offset.

After going through the server logs I found that there is an issue with my code. One of ValueChangeListeners added to this table failed with NPE. I’m not sure if it caused NPE mentioned in this first post, but I believe it might have.

I will be able to tell if fixing NPE in listener resolved my problem only after the server environment is updated. In the meantime - can such listener mess Table’s lifecycle?

It might be possible if the exception occurs between some operation that resets the internal buffers of the Table server side component and re-rendering the Table.

Sorry for re-opening a 5 year old discussion, but looks like the problem still exists, at least in the 7.5 stream.
I attached a snippet to reproduce at issue https://dev.vaadin.com/ticket/13649
Bad thing on this is that the application even doesn’t recover after Browser refresh. So affected users either have to remove their session cookie or restart the server :frowning:

Edit: Attached a patch to the aforementioned ticket that resolves the issue.