Why a Table.CacheUpdateException is raised whenever I add an item to a Vaa

Hi everyone why if I add an item in a hardcoded way to a Vaadin Table with ColumnGenerators I always get a Table.CacheUpdateException?

Here is the code:

// Generated Table columns

        Table tableWithGeneratedCol = new Table();

        

        tableWithGeneratedCol.addContainerProperty(

                "date",     Date.class,   null, "Date",         null, null);

        tableWithGeneratedCol.addContainerProperty(

                "quantity", Double.class, null, "Quantity (l)", null, null);

        tableWithGeneratedCol.addContainerProperty(

                "price",    Double.class, null, "Price (e/l)",  null, null);

        tableWithGeneratedCol.addContainerProperty(

                "total",    Double.class, null, "Total (e)",    null, null);

    

        

        tableWithGeneratedCol.addItem(new Object[] { new GregorianCalendar().getTime(), // date column

                                                     new Double(10),                     // quantity column

                                                     new Double(10),                    // price column

                                                     new Double(0)                    // total column

                                                    }, 1); // itemId

        tableWithGeneratedCol.addItem(new Object[] { new GregorianCalendar().getTime(),

                                                     new Double(16.2),                     // quantity column

                                                     new Double(21.2),                    // price column

                                                     new Double(0)                        // total column

                                                    }, 2); // itemId

        tableWithGeneratedCol.addItem(new Object[] { new GregorianCalendar().getTime(),

                                                     new Double(10),                     // quantity column

                                                     new Double(22),                    // price column

                                                     new Double(0)                    // total column                                            

                                                    }, 3); // itemId

        tableWithGeneratedCol.addItem(new Object[] { new GregorianCalendar().getTime(),

                                                     new Double(10),                     // quantity column

                                                     new Double(20),                    // price column

                                                     new Double(0)                    // total column

                                                    }, 4); // itemId

        tableWithGeneratedCol.addItem(new Object[] { new GregorianCalendar().getTime(),

                                                     new Double(15),                     // quantity column

                                                     new Double(19.12),                    // price column

                                                     new Double(0)                                            

                                                    }, 5); // itemId

        tableWithGeneratedCol.addItem(new Object[] { new GregorianCalendar().getTime(),

                                                     new Double(10),                     // quantity column

                                                     new Double(20.30),                    // price column

                                                     new Double(0)                    // total column        

                                                    }, 6); // itemId

        tableWithGeneratedCol.addItem(new Object[] { new GregorianCalendar().getTime(),

                                                     new Double(50),                     // quantity column

                                                     new Double(32.89),                    // price column

                                                     new Double(0)                    // total column

                                                    }, 7); // itemId

Now if I add another item:

...
tableWithGeneratedCol.addItem(new Object[] { new GregorianCalendar().getTime(),

                 new Double(50),                     // quantity column

                 new Double(32.89),                    // price column

                 new Double(0)                    // total column

                }, 8); // itemId

If I reload the page a
Table.CacheUpdateException
is thrown.
Here is the exception:

SEVERE: 
com.vaadin.ui.Table$CacheUpdateException: Error during Table cache update. Additional causes not shown.

    at com.vaadin.ui.Table.maybeThrowCacheUpdateExceptions(Table.java:1739)

    at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1728)

    at com.vaadin.ui.Table.attach(Table.java:4244)

    at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:484)

    at com.vaadin.ui.AbstractComponentContainer.addComponent(AbstractComponentContainer.java:210)

    at com.vaadin.ui.AbstractOrderedLayout.addComponent(AbstractOrderedLayout.java:90)

    at com.example.table_chapter_5_21.TableUI.init(TableUI.java:357)

    at com.vaadin.ui.UI.doInit(UI.java:645)

    at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:222)

    at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:74)

    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)

    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1406)

    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:305)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)

    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)

    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085)

    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)

    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)

    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556)

    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

    at java.lang.Thread.run(Thread.java:745)

Caused by: java.lang.NullPointerException

    at java.util.Calendar.setTime(Calendar.java:1770)

    at java.text.SimpleDateFormat.format(SimpleDateFormat.java:943)

    at java.text.SimpleDateFormat.format(SimpleDateFormat.java:936)

    at java.text.DateFormat.format(DateFormat.java:345)

    at com.example.table_chapter_5_21.DateColumnGenerator.generateCell(DateColumnGenerator.java:27)

    at com.example.table_chapter_5_21.DateColumnGenerator.generateCell(DateColumnGenerator.java:1)

    at com.vaadin.ui.Table.parseItemIdToCells(Table.java:2334)

    at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:2195)

    at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1717)

    ... 34 more




Dec 19, 2014 10:24:58 PM org.apache.catalina.core.StandardWrapperValve invoke

SEVERE: Servlet.service() for servlet [com.example.table_chapter_5_21.TableUI$Servlet]
 in context with path 
[/Table_Chapter_5.21] threw exception [com.vaadin.server.ServiceException: com.vaadin.ui.Table$CacheUpdateException: Error during Table cache update. Additional causes not shown.]
 with root cause

java.lang.NullPointerException

    at java.util.Calendar.setTime(Calendar.java:1770)

    at java.text.SimpleDateFormat.format(SimpleDateFormat.java:943)

    at java.text.SimpleDateFormat.format(SimpleDateFormat.java:936)

    at java.text.DateFormat.format(DateFormat.java:345)

    at com.example.table_chapter_5_21.DateColumnGenerator.generateCell(DateColumnGenerator.java:27)

    at com.example.table_chapter_5_21.DateColumnGenerator.generateCell(DateColumnGenerator.java:1)

    at com.vaadin.ui.Table.parseItemIdToCells(Table.java:2334)

    at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:2195)

    at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1717)

    at com.vaadin.ui.Table.attach(Table.java:4244)

    at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:484)

    at com.vaadin.ui.AbstractComponentContainer.addComponent(AbstractComponentContainer.java:210)

    at com.vaadin.ui.AbstractOrderedLayout.addComponent(AbstractOrderedLayout.java:90)

    at com.example.table_chapter_5_21.TableUI.init(TableUI.java:357)

    at com.vaadin.ui.UI.doInit(UI.java:645)

    at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:222)

    at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:74)

    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)

    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1406)

    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:305)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)

    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)

    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085)

    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)

    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)

    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556)

    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

    at java.lang.Thread.run(Thread.java:745)

I have noticed then that if I wait for a while and then reload the page, everything starts work again, anyway, why this exception is thrown? Why with tables with generated columns?

Thanks for the attention! Hope for some elucidations!

Strange. The error happens because the Table tries to format a cell that contains a Date, but stumbles on a nullpointer:

java.lang.NullPointerException
    at java.util.Calendar.setTime(Calendar.java:1770)
    at java.text.SimpleDateFormat.format(SimpleDateFormat.java:943

I wonder, why does it get a null? Could you debug this, and see where the null comes from? It might just be a bug in the DateColumnGenerator class, but it could be a bug in Vaadin too.

in my case, null pointer exception was to blame :

Caused by: java.lang.NullPointerException
        at ui.business.catering.firme.dugovanja.Bilans_Table.lambda$generateCheckBoxColumn$8823cd$1(Bilans_Table.java:177)