I keep encountering the following exception:
java.lang.NullPointerException
at com.vaadin.terminal.gwt.server.CommunicationManager.getDirtyVisibleComponents(CommunicationManager.java:1232)
at com.vaadin.terminal.gwt.server.CommunicationManager.paintAfterVariablechanges(CommunicationManager.java:401)
at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:314)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:425)
at com.ibm.rtc.application.WebPortalApplicationServlet.service(WebPortalApplicationServlet.java:21)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
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:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
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:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:735)
When I trace through the code, starting at getDirtyVisibleComponents, I noticed a piece of code that seems to be an unchecked null object condition. It is red bold in the code below. According to the docs, component.getWindow() can return a null when the component does not yet have a parent window. I’m using Vaddin 6.1.3.
private ArrayList<Paintable> getDirtyVisibleComponents(Window w) {
final ArrayList<Paintable> resultset = new ArrayList<Paintable>(
dirtyPaintabletSet);
// The following algorithm removes any components that would be painted
// as a direct descendant of other components from the dirty components
// list. The result is that each component should be painted exactly
// once and any unmodified components will be painted as "cached=true".
for (final Iterator i = dirtyPaintabletSet.iterator(); i.hasNext();) {
final Paintable p = (Paintable) i.next();
if (p instanceof Component) {
final Component component = (Component) p;
if (component.getApplication() == null) {
// component is detached after requestRepaint is called
resultset.remove(p);
i.remove();
} else {
[color=#FF0000]
[b]
Window componentsRoot = component.getWindow();
if (componentsRoot.getParent() != null) {
// this is a subwindow
componentsRoot = (Window) componentsRoot.getParent();
}
[/b]
[/color]
if (componentsRoot != w) {
resultset.remove(p);
} else if (component.getParent() != null
&& !component.getParent().isVisible()) {
/*
* Do not return components in an invisible subtree.
*
* Components that are invisible in visible subree, must
* be rendered (to let client know that they need to be
* hidden).
*/
resultset.remove(p);
}
}
}
}
return resultset;
}
I see this occur when I do something like this:
... add the component to the page
[code]
mainLayoutArea.addComponent(new AdminUI((MainApplication)getApplication()));
[/code]
…
// button click on the page calls this method
[code]
public void buttonClick_Admin(ClickEvent event) {
mainLayoutArea.removeAllComponents();
mainLayoutArea.addComponent(new AdminUI((MainApplication)getApplication()));
}
[/code]