java.lang.NullPointerException

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

    (only when listbox + CE) EE doesn't have this issue the code is simulating mvvm behavior {code} <zk> <label multiline="true"> (only when listbox + CE) EE doesn't have this issue the code is simulating mvvm behavior 1.chick addToSelection you should see a item A add to next page without an exception 2.this exception cause by a wrong implementation of object's hashcode() 3.should consider to avoid this exception (eat at org.zkoss.zul.Listbox.setSelectedIndex(Listbox.java:929)(need to check side effect) or throw meaningful exception(better) </label> <div width="400px" > <listbox id="listbox" mold="paging" pageSize="10"> <listhead> <listheader label="name" /> </listhead> <template name="model" > <listitem> <listcell label="${each.name}" /> </listitem> </template> </listbox> <button label="addToSelection" onClick="addToSelection()"/> </div> <zscript><![CDATA[ class Item { String name; public Item() { } public Item(String name) { this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((name == null) ? 0 : name.hashCode()); return result; } public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof Item)) return false; Item other = (Item) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; return true; } } List itemList = new LinkedList(); for (int i = 0; i < 10; i++) { itemList.add(new Item("item " + i)); } ListModelList listModelList = new ListModelList(itemList,true);//if use live list listbox.setModel(listModelList); //1.an item is not in collection yet, however, it already in the selection Item n = new Item(); listModelList.addSelection(n);//un non in list selection public void addToSelection() { //2.after the value changed of the item //the wrong imple of item hash cause this exception n.setName("A"); itemList.add(n); listModelList.addSelection(n); listbox.setModel(listModelList); } ]]> </zscript> </zk> {code} >>java.lang.NullPointerException >> at org.zkoss.zul.Listbox.setSelectedIndex(Listbox.java:929) >> at org.zkoss.zul.Listbox.onListDataChange(Listbox.java:2531) >> at org.zkoss.zul.Listbox.access$17(Listbox.java:2521) >> at org.zkoss.zul.Listbox$4.onChange(Listbox.java:461) >> at org.zkoss.zul.AbstractListModel.fireEvent(AbstractListModel.java:61) >> at org.zkoss.zul.ListModelList.fireSelectionEvent(ListModelList.java:438) >> at org.zkoss.zul.AbstractListModel.addToSelection(AbstractListModel.java:130) >> at org.zkoss.zul.ListModelList.addSelection(ListModelList.java:445) >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) >> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) >> at java.lang.reflect.Method.invoke(Method.java:597) >> at bsh.Reflect.invokeMethod(Unknown Source) >> at bsh.Reflect.invokeObjectMethod(Unknown Source) >> at bsh.Name.invokeMethod(Unknown Source) >> at bsh.BSHMethodInvocation.eval(Unknown Source) >> at bsh.BSHPrimaryExpression.eval(Unknown Source) >> at bsh.BSHPrimaryExpression.eval(Unknown Source) >> at bsh.BSHBlock.evalBlock(Unknown Source) >> at bsh.BSHBlock.eval(Unknown Source) >> at bsh.BshMethod.invokeImpl(Unknown Source) >> at bsh.BshMethod.invoke(Unknown Source) >> at bsh.BshMethod.invoke(Unknown Source) >> at bsh.Name.invokeLocalMethod(Unknown Source) >> at bsh.Name.invokeMethod(Unknown Source) >> at bsh.BSHMethodInvocation.eval(Unknown Source) >> at bsh.BSHPrimaryExpression.eval(Unknown Source) >> at bsh.BSHPrimaryExpression.eval(Unknown Source) >> at bsh.Interpreter.eval(Unknown Source) >> at bsh.Interpreter.eval(Unknown Source) >> at org.zkoss.zk.scripting.bsh.BSHInterpreter.exec(BSHInterpreter.java:131) >> at org.zkoss.zk.scripting.util.GenericInterpreter.interpret(GenericInterpreter.java:328) >> at org.zkoss.zk.ui.impl.PageImpl.interpret(PageImpl.java:875) >> at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2701) >> at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2654) >> at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:136) >> at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1710) >> at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1495) >> at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1205) >> at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:583) >> at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:481) >> at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:489) >> at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) >> at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) >> at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) >> at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401) >> at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) >> at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) >> at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766) >> at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450) >> at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) >> at org.mortbay.jetty.Server.handle(Server.java:326) >> at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) >> at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945) >> at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756) >> at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218) >> at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) >> at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410) >> at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

    ZK-Tracker | 4 years ago | dennis
    java.lang.NullPointerException
  2. 0

    (only when listbox + CE) EE doesn't have this issue the code is simulating mvvm behavior {code} <zk> <label multiline="true"> (only when listbox + CE) EE doesn't have this issue the code is simulating mvvm behavior 1.chick addToSelection you should see a item A add to next page without an exception 2.this exception cause by a wrong implementation of object's hashcode() 3.should consider to avoid this exception (eat at org.zkoss.zul.Listbox.setSelectedIndex(Listbox.java:929)(need to check side effect) or throw meaningful exception(better) </label> <div width="400px" > <listbox id="listbox" mold="paging" pageSize="10"> <listhead> <listheader label="name" /> </listhead> <template name="model" > <listitem> <listcell label="${each.name}" /> </listitem> </template> </listbox> <button label="addToSelection" onClick="addToSelection()"/> </div> <zscript><![CDATA[ class Item { String name; public Item() { } public Item(String name) { this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((name == null) ? 0 : name.hashCode()); return result; } public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof Item)) return false; Item other = (Item) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; return true; } } List itemList = new LinkedList(); for (int i = 0; i < 10; i++) { itemList.add(new Item("item " + i)); } ListModelList listModelList = new ListModelList(itemList,true);//if use live list listbox.setModel(listModelList); //1.an item is not in collection yet, however, it already in the selection Item n = new Item(); listModelList.addSelection(n);//un non in list selection public void addToSelection() { //2.after the value changed of the item //the wrong imple of item hash cause this exception n.setName("A"); itemList.add(n); listModelList.addSelection(n); listbox.setModel(listModelList); } ]]> </zscript> </zk> {code} >>java.lang.NullPointerException >> at org.zkoss.zul.Listbox.setSelectedIndex(Listbox.java:929) >> at org.zkoss.zul.Listbox.onListDataChange(Listbox.java:2531) >> at org.zkoss.zul.Listbox.access$17(Listbox.java:2521) >> at org.zkoss.zul.Listbox$4.onChange(Listbox.java:461) >> at org.zkoss.zul.AbstractListModel.fireEvent(AbstractListModel.java:61) >> at org.zkoss.zul.ListModelList.fireSelectionEvent(ListModelList.java:438) >> at org.zkoss.zul.AbstractListModel.addToSelection(AbstractListModel.java:130) >> at org.zkoss.zul.ListModelList.addSelection(ListModelList.java:445) >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) >> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) >> at java.lang.reflect.Method.invoke(Method.java:597) >> at bsh.Reflect.invokeMethod(Unknown Source) >> at bsh.Reflect.invokeObjectMethod(Unknown Source) >> at bsh.Name.invokeMethod(Unknown Source) >> at bsh.BSHMethodInvocation.eval(Unknown Source) >> at bsh.BSHPrimaryExpression.eval(Unknown Source) >> at bsh.BSHPrimaryExpression.eval(Unknown Source) >> at bsh.BSHBlock.evalBlock(Unknown Source) >> at bsh.BSHBlock.eval(Unknown Source) >> at bsh.BshMethod.invokeImpl(Unknown Source) >> at bsh.BshMethod.invoke(Unknown Source) >> at bsh.BshMethod.invoke(Unknown Source) >> at bsh.Name.invokeLocalMethod(Unknown Source) >> at bsh.Name.invokeMethod(Unknown Source) >> at bsh.BSHMethodInvocation.eval(Unknown Source) >> at bsh.BSHPrimaryExpression.eval(Unknown Source) >> at bsh.BSHPrimaryExpression.eval(Unknown Source) >> at bsh.Interpreter.eval(Unknown Source) >> at bsh.Interpreter.eval(Unknown Source) >> at org.zkoss.zk.scripting.bsh.BSHInterpreter.exec(BSHInterpreter.java:131) >> at org.zkoss.zk.scripting.util.GenericInterpreter.interpret(GenericInterpreter.java:328) >> at org.zkoss.zk.ui.impl.PageImpl.interpret(PageImpl.java:875) >> at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2701) >> at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2654) >> at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:136) >> at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1710) >> at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1495) >> at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1205) >> at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:583) >> at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:481) >> at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:489) >> at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) >> at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) >> at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) >> at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401) >> at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) >> at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) >> at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766) >> at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450) >> at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) >> at org.mortbay.jetty.Server.handle(Server.java:326) >> at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) >> at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945) >> at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756) >> at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218) >> at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) >> at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410) >> at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

    ZK-Tracker | 4 years ago | dennis
    java.lang.NullPointerException

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.zkoss.zul.Listbox.setSelectedIndex()
    2. ZK XUL Components
      ListModelList.addSelection
      1. org.zkoss.zul.Listbox.setSelectedIndex(Listbox.java:929)
      2. org.zkoss.zul.Listbox.onListDataChange(Listbox.java:2531)
      3. org.zkoss.zul.Listbox.access$17(Listbox.java:2521)
      4. org.zkoss.zul.Listbox$4.onChange(Listbox.java:461)
      5. org.zkoss.zul.AbstractListModel.fireEvent(AbstractListModel.java:61)
      6. org.zkoss.zul.ListModelList.fireSelectionEvent(ListModelList.java:438)
      7. org.zkoss.zul.AbstractListModel.addToSelection(AbstractListModel.java:130)
      8. org.zkoss.zul.ListModelList.addSelection(ListModelList.java:445)
      8 frames
    3. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    4. BeanShell
      Interpreter.eval
      1. bsh.Reflect.invokeMethod(Unknown Source)
      2. bsh.Reflect.invokeObjectMethod(Unknown Source)
      3. bsh.Name.invokeMethod(Unknown Source)
      4. bsh.BSHMethodInvocation.eval(Unknown Source)
      5. bsh.BSHPrimaryExpression.eval(Unknown Source)
      6. bsh.BSHPrimaryExpression.eval(Unknown Source)
      7. bsh.BSHBlock.evalBlock(Unknown Source)
      8. bsh.BSHBlock.eval(Unknown Source)
      9. bsh.BshMethod.invokeImpl(Unknown Source)
      10. bsh.BshMethod.invoke(Unknown Source)
      11. bsh.BshMethod.invoke(Unknown Source)
      12. bsh.Name.invokeLocalMethod(Unknown Source)
      13. bsh.Name.invokeMethod(Unknown Source)
      14. bsh.BSHMethodInvocation.eval(Unknown Source)
      15. bsh.BSHPrimaryExpression.eval(Unknown Source)
      16. bsh.BSHPrimaryExpression.eval(Unknown Source)
      17. bsh.Interpreter.eval(Unknown Source)
      18. bsh.Interpreter.eval(Unknown Source)
      18 frames
    5. ZK Kernel
      DHtmlUpdateServlet.doPost
      1. org.zkoss.zk.scripting.bsh.BSHInterpreter.exec(BSHInterpreter.java:131)
      2. org.zkoss.zk.scripting.util.GenericInterpreter.interpret(GenericInterpreter.java:328)
      3. org.zkoss.zk.ui.impl.PageImpl.interpret(PageImpl.java:875)
      4. org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2701)
      5. org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2654)
      6. org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:136)
      7. org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1710)
      8. org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1495)
      9. org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1205)
      10. org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:583)
      11. org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:481)
      12. org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:489)
      12 frames
    6. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      2. javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
      2 frames
    7. Jetty Server
      SelectChannelEndPoint.run
      1. org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
      2. org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
      3. org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      4. org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
      5. org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
      6. org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
      7. org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      8. org.mortbay.jetty.Server.handle(Server.java:326)
      9. org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
      10. org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
      11. org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
      12. org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
      13. org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
      14. org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
      14 frames
    8. Jetty Util
      QueuedThreadPool$PoolThread.run
      1. org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
      1 frame