java.lang.NullPointerException

ZK-Tracker | hiepgau | 1 year ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    when you has a tree at latest three level. with init with all node is closed. add code to set isOpen = true to all node to expand all tree node. with prev 8.0.0, code do well and all job done at one request. from 8.0.0 it will create node at first request, and do render at second request (second request fire by javascript code and is fire ON_RENDER event) code at tree class, block handle event ON_RENDER: {code:java} for (Treeitem ti : items) { if (ti.isRendered()) continue; int i = ti.getIndex(); if (maxItem == null) { maxItem = ti; maxIndex = i; } if (i > maxIndex) { maxItem = ti; maxIndex = i; } ti.getChildren().clear(); Treechildren parent = (Treechildren) ti.getParent(); Object childNode = getAssociatedNode(ti, this); renderChildren0(renderer, parent, ti, childNode, i); } {code} when render node at level 2. line ti.getChildren().clear(); will clear all child node. so when render not at level 3 code getAssociatedNode(ti, this) thru a NPE. below is code to re-proceduce bug: {code:java} // build tree when init page DefaultTreeNode<String> rootNode = new DefaultTreeNode<>("root", new ArrayList<DefaultTreeNode<String>>()); addChildNode (rootNode, 1, 3); for (TreeNode<String> nodeLv1:rootNode.getChildren()){ addChildNode (nodeLv1, 2, 3); for (TreeNode<String> nodeLv2:nodeLv1.getChildren()){ addChildNode (nodeLv2, 3, 3); } } DefaultTreeModel<String> model = new DefaultTreeModel<>(rootNode); expandAllTree = new Tree(); expandAllTree.setModel(model); this.appendChild(expandAllTree); // function add child node public void addChildNode (TreeNode<String> node, int level, int num){ for (int i = 0; i < num; i++){ DefaultTreeNode<String> child = new DefaultTreeNode<String> (String.valueOf(level) + "_" + String.valueOf(i), new ArrayList<DefaultTreeNode<String>>()); node.add(child); } } // function to expand tree protected void collapseTree (Component treeObject, boolean isOpen){ if (treeObject instanceof Treeitem) { Treeitem treeitem = (Treeitem) treeObject; treeitem.setOpen(isOpen); } Collection<?> com = treeObject.getChildren(); if (com != null) { for (Iterator<?> iterator = com.iterator(); iterator.hasNext();) { collapseTree((Component) iterator.next(), isOpen); } } } // call collapseTree in event handle button collapseTree (expandAllTree, true); {code} below is full NPE message java.lang.NullPointerException at org.zkoss.zul.Tree.getTreeitemPath(Tree.java:2385) at org.zkoss.zul.Tree.getAssociatedNode(Tree.java:2372) at org.zkoss.zul.Tree.service(Tree.java:2749) at org.zkoss.zk.ui.impl.DesktopImpl.service(DesktopImpl.java:713) at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1306) at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:611) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:485) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:494) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:821) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1685) at org.eclipse.jetty.servlets.PushCacheFilter.doFilter(PushCacheFilter.java:119) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:581) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119) at org.eclipse.jetty.server.Server.handle(Server.java:517) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95) at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572) at java.lang.Thread.run(Thread.java:745)

    ZK-Tracker | 1 year ago | hiepgau
    java.lang.NullPointerException
  2. 0

    when you has a tree at latest three level. with init with all node is closed. add code to set isOpen = true to all node to expand all tree node. with prev 8.0.0, code do well and all job done at one request. from 8.0.0 it will create node at first request, and do render at second request (second request fire by javascript code and is fire ON_RENDER event) code at tree class, block handle event ON_RENDER: {code:java} for (Treeitem ti : items) { if (ti.isRendered()) continue; int i = ti.getIndex(); if (maxItem == null) { maxItem = ti; maxIndex = i; } if (i > maxIndex) { maxItem = ti; maxIndex = i; } ti.getChildren().clear(); Treechildren parent = (Treechildren) ti.getParent(); Object childNode = getAssociatedNode(ti, this); renderChildren0(renderer, parent, ti, childNode, i); } {code} when render node at level 2. line ti.getChildren().clear(); will clear all child node. so when render not at level 3 code getAssociatedNode(ti, this) thru a NPE. below is code to re-proceduce bug: {code:java} // build tree when init page DefaultTreeNode<String> rootNode = new DefaultTreeNode<>("root", new ArrayList<DefaultTreeNode<String>>()); addChildNode (rootNode, 1, 3); for (TreeNode<String> nodeLv1:rootNode.getChildren()){ addChildNode (nodeLv1, 2, 3); for (TreeNode<String> nodeLv2:nodeLv1.getChildren()){ addChildNode (nodeLv2, 3, 3); } } DefaultTreeModel<String> model = new DefaultTreeModel<>(rootNode); expandAllTree = new Tree(); expandAllTree.setModel(model); this.appendChild(expandAllTree); // function add child node public void addChildNode (TreeNode<String> node, int level, int num){ for (int i = 0; i < num; i++){ DefaultTreeNode<String> child = new DefaultTreeNode<String> (String.valueOf(level) + "_" + String.valueOf(i), new ArrayList<DefaultTreeNode<String>>()); node.add(child); } } // function to expand tree protected void collapseTree (Component treeObject, boolean isOpen){ if (treeObject instanceof Treeitem) { Treeitem treeitem = (Treeitem) treeObject; treeitem.setOpen(isOpen); } Collection<?> com = treeObject.getChildren(); if (com != null) { for (Iterator<?> iterator = com.iterator(); iterator.hasNext();) { collapseTree((Component) iterator.next(), isOpen); } } } // call collapseTree in event handle button collapseTree (expandAllTree, true); {code} below is full NPE message java.lang.NullPointerException at org.zkoss.zul.Tree.getTreeitemPath(Tree.java:2385) at org.zkoss.zul.Tree.getAssociatedNode(Tree.java:2372) at org.zkoss.zul.Tree.service(Tree.java:2749) at org.zkoss.zk.ui.impl.DesktopImpl.service(DesktopImpl.java:713) at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1306) at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:611) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:485) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:494) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:821) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1685) at org.eclipse.jetty.servlets.PushCacheFilter.doFilter(PushCacheFilter.java:119) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:581) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119) at org.eclipse.jetty.server.Server.handle(Server.java:517) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95) at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572) at java.lang.Thread.run(Thread.java:745)

    ZK-Tracker | 1 year ago | hiepgau
    java.lang.NullPointerException
  3. 0

    Getting a nullpointer exception when switching displayables in J2ME

    Stack Overflow | 6 years ago | Pallinder
    java.lang.NullPointerException: 0 at javax.microedition.lcdui.Display$ChameleonTunnel.callScreenListener(), bci=46 at com.sun.midp.chameleon.layers.SoftButtonLayer.processCommand(), bci=74 at com.sun.midp.chameleon.layers.SoftButtonLayer.soft1(), bci=37 at com.sun.midp.chameleon.layers.SoftButtonLayer.keyInput(), bci=36 at com.sun.midp.chameleon.CWindow.keyInput(), bci=38 at javax.microedition.lcdui.Display$DisplayEventConsumerImpl.handleKeyEvent(), bci=17 at com.sun.midp.lcdui.DisplayEventListener.process(), bci=277 at com.sun.midp.events.EventQueue.run(), bci=179
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    J2ME (Java) - Null Pointer Exception caught in Display Class

    Stack Overflow | 6 years ago | Tom
    java.lang.NullPointerException: 0 at javax.microedition.lcdui.Display$ChameleonTunnel.callScreenListener(), bci=46 at com.sun.midp.chameleon.layers.SoftButtonLayer.processCommand(), bci=74 at com.sun.midp.chameleon.layers.SoftButtonLayer.soft1(), bci=37 at com.sun.midp.chameleon.layers.SoftButtonLayer.keyInput(), bci=36 at com.sun.midp.chameleon.CWindow.keyInput(), bci=38 at javax.microedition.lcdui.Display$DisplayEventConsumerImpl.handleKeyEvent(), bci=17 at com.sun.midp.lcdui.DisplayEventListener.process(), bci=277 at com.sun.midp.events.EventQueue.run(), bci=179
  6. 0

    Cloud Foundry v2 in Grails

    Stack Overflow | 3 years ago | angelo087
    java.lang.NullPointerException: Cannot invoke method getAt() on null object

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.zkoss.zul.Tree.getTreeitemPath()
    2. ZK XUL Components
      Tree.service
      1. org.zkoss.zul.Tree.getTreeitemPath(Tree.java:2385)
      2. org.zkoss.zul.Tree.getAssociatedNode(Tree.java:2372)
      3. org.zkoss.zul.Tree.service(Tree.java:2749)
      3 frames
    3. ZK Kernel
      DHtmlUpdateServlet.doPost
      1. org.zkoss.zk.ui.impl.DesktopImpl.service(DesktopImpl.java:713)
      2. org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1306)
      3. org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:611)
      4. org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:485)
      5. org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:494)
      5 frames
    4. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
      2. javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
      2 frames
    5. Jetty
      SelectChannelEndPoint$2.run
      1. org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:821)
      2. org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1685)
      3. org.eclipse.jetty.servlets.PushCacheFilter.doFilter(PushCacheFilter.java:119)
      4. org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668)
      5. org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:581)
      6. org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
      7. org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
      8. org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
      9. org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158)
      10. org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
      11. org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
      12. org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090)
      13. org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
      14. org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)
      15. org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
      16. org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
      17. org.eclipse.jetty.server.Server.handle(Server.java:517)
      18. org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308)
      19. org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
      20. org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
      21. org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
      22. org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
      22 frames
    6. org.eclipse.jetty
      ExecuteProduceConsume.run
      1. org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
      2. org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
      2 frames
    7. Jetty
      QueuedThreadPool$3.run
      1. org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
      2. org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
      2 frames
    8. Java RT
      Thread.run
      1. java.lang.Thread.run(Thread.java:745)
      1 frame