The problem I struggled with for days...
Take a simple Vaadin tab sheet.Add a sheet , remove a sheet etc. Nothing hard at all right ?
I was getting the below error when the screen was repainted.
SEVERE: Terminal error: java.lang.NullPointerException at com.vaadin.ui.TabSheet.paintContent(TabSheet.java:390) at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:781) at com.vaadin.ui.AbstractSplitPanel.paintContent(AbstractSplitPanel.java:235) at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:781) at com.vaadin.ui.AbstractOrderedLayout.paintContent(AbstractOrderedLayout.java:187) at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:781) at com.vaadin.ui.Panel.paintContent(Panel.java:269) at com.vaadin.ui.Window.paintContent(Window.java:641) at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:781) at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.writeUidlResponce(AbstractCommunicationManager.java:1046) at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.paintAfterVariableChanges(AbstractCommunicationManager.java:927) at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:794) at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:296) at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:169) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:168) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:304) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722)
There seems to be a Vaadin ticket for this : http://dev.vaadin.com/ticket/4179
The culprit
My favorite java Add On : LombokActually I can't blame Lombok or Vaadin, this is my misuse of Lombok inside Vaadin
I decorated my component with @Data
That means the equals and hashCode were generated by all the fields in the class.
com.vaadin.ui.TabSheet.java contains an internal representation of the tabs in a HashMap tabs.
If the hashmap can not find your component because the equals has changed. you will get what I did.
Tab tab = tabs.get(component);//will return null target.startTag("tab"); if (!tab.isEnabled() && tab.isVisible()) {
* You can use @EqualsAndHashCode(of={"myid"})
ReplyDeleteso only that is used
* I recently stabbed myself with lombok too :)
I used @Getter(lazy=true)
which makes sort of an immutable singleton out of the value. The problem was it should have changed on certain conditions (which IMO should not have happened) So I think I need to make an immutable value builder for that case..
* do you read these comments?
Thanks.
ReplyDeleteYes, I read the comments :)