Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-3847

Include invalidate cause an NPE when WebSocket is enabled

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 8.5.0, 8.5.1
    • Fix Version/s: 8.5.1.1
    • Component/s: None
    • Security Level: Jimmy
    • Labels:
      None
    • Environment:

      ZK EE 8.5.0

      only happened using Apache Tomcat - reproduced with both 8.5.23 and latest 8.5.28)

      Description

      I have this code:
      {{
      Page desktopPage = Executions.getCurrent().getDesktop().getPageIfAny("main");
      Div center = (Div) desktopPage.getFellow("dashBoardCenter");
      Include include = (Include) center.getFellow("dashBoardPage");
      include.removeAttribute("params");
      include.setSrc(page);
      include.invalidate();
      }}

      If the websockets are enabled in zk.xml

      {{<listener>
      <listener-class>org.zkoss.zkmax.au.websocket.WebSocketWebAppInit</listener-class>
      </listener>}}

      I receive this error:

      {{GRAVE:
      java.lang.NullPointerException
      at org.apache.catalina.connector.Response.setLocale(Response.java:907)
      at org.apache.catalina.connector.ResponseFacade.setLocale(ResponseFacade.java:357)
      at javax.servlet.ServletResponseWrapper.setLocale(ServletResponseWrapper.java:196)
      at javax.servlet.ServletResponseWrapper.setLocale(ServletResponseWrapper.java:196)
      at org.zkoss.web.servlet.Charsets.setup(Charsets.java:92)
      at org.zkoss.web.servlet.Charsets.setup(Charsets.java:132)
      at org.zkoss.web.util.resource.ClassWebResource.service(ClassWebResource.java:270)
      at org.zkoss.zk.ui.http.ExecutionImpl.dispatch(ExecutionImpl.java:242)
      at org.zkoss.zk.ui.http.ExecutionImpl.include(ExecutionImpl.java:203)
      at org.zkoss.zul.Include.include(Include.java:706)
      at org.zkoss.zul.Include.renderProperties(Include.java:628)
      at org.zkoss.zk.ui.AbstractComponent.redraw(AbstractComponent.java:2153)
      at org.zkoss.zk.ui.impl.UiVisualizer.redraw(UiVisualizer.java:1003)
      at org.zkoss.zk.ui.impl.UiVisualizer.getResponses(UiVisualizer.java:699)
      at org.zkoss.zk.ui.impl.UiEngineImpl.getResponses(UiEngineImpl.java:1531)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1337)
      at org.zkoss.zkmax.au.websocket.WebSocketEndPoint.process(WebSocketEndPoint.java:245)
      at org.zkoss.zkmax.au.websocket.WebSocketEndPoint.access$000(WebSocketEndPoint.java:61)
      at org.zkoss.zkmax.au.websocket.WebSocketEndPoint$1.onMessage(WebSocketEndPoint.java:107)
      at org.zkoss.zkmax.au.websocket.WebSocketEndPoint$1.onMessage(WebSocketEndPoint.java:104)
      at org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:399)
      at org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:500)
      at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:295)
      at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:131)
      at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:67)
      at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler$WsReadListener.onDataAvailable(WsHttpUpgradeHandler.java:204)
      at org.apache.coyote.http11.upgrade.AbstractServletInputStream.onDataAvailable(AbstractServletInputStream.java:203)
      at org.apache.coyote.http11.upgrade.AbstractProcessor.upgradeDispatch(AbstractProcessor.java:93)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:635)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1770)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1729)
      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:748)}}

      That doesn't happens when WebSockets are disabled

        Issue Links

          Activity

          Hide
          JoseWalker JoseWalker added a comment -

          I've reported the ZK-3810 bug before, and the solution provided it was working with the version 8.5.0 version.
          Now with this 8.5.1 version, the solution provided to the 3810 bug, is not working, and I get the same result that is being described here:

          {{GRAVE:
          java.lang.NullPointerException
          at org.apache.catalina.connector.Response.setLocale(Response.java:907) ..............

          Please, this WebSockets features has long waited! and it seems nobody can benefit of it because of it.

          Thanks!

          Show
          JoseWalker JoseWalker added a comment - I've reported the ZK-3810 bug before, and the solution provided it was working with the version 8.5.0 version. Now with this 8.5.1 version, the solution provided to the 3810 bug, is not working, and I get the same result that is being described here: {{GRAVE: java.lang.NullPointerException at org.apache.catalina.connector.Response.setLocale(Response.java:907) .............. Please, this WebSockets features has long waited! and it seems nobody can benefit of it because of it. Thanks!
          Hide
          cor3000 cor3000 added a comment - - edited

          in 8.5.1 the workaround mentioned in ZK-3810 is no longer necessary, I personally verified that.
          Also executing the code mentioned in the example above doesn't produce the NPE (neither in 8.5.0, nor in 8.5.1)

          I tried this...

          <?page id="main"?>
          <zk>
          	<div id="dashBoardCenter">
          		<include id="dashBoardPage" src="include1.zul"/>
          	</div>
          	<button label="change include">
          		<attribute name="onClick"><![CDATA[
          			String pageUrl = "include2.zul";
          			Page desktopPage = Executions.getCurrent().getDesktop().getPageIfAny("main");
          			Div center = (Div) desktopPage.getFellow("dashBoardCenter");
          			Include include = (Include) center.getFellow("dashBoardPage");
          			include.removeAttribute("params");
          			include.setSrc(pageUrl);
          			include.invalidate();
          		]]></attribute>
          	</button>
          </zk>

          Can someone please provide a reproducing example for this case? Or add the missing information to my given example?

          Show
          cor3000 cor3000 added a comment - - edited in 8.5.1 the workaround mentioned in ZK-3810 is no longer necessary, I personally verified that. Also executing the code mentioned in the example above doesn't produce the NPE (neither in 8.5.0, nor in 8.5.1) I tried this... <?page id= "main" ?> <zk> <div id= "dashBoardCenter" > <include id= "dashBoardPage" src= "include1.zul" /> </div> <button label= "change include" > <attribute name= "onClick" > <![CDATA[ String pageUrl = "include2.zul" ; Page desktopPage = Executions.getCurrent().getDesktop().getPageIfAny( "main" ); Div center = (Div) desktopPage.getFellow( "dashBoardCenter" ); Include include = (Include) center.getFellow( "dashBoardPage" ); include.removeAttribute( "params" ); include.setSrc(pageUrl); include.invalidate(); ]]> </attribute> </button> </zk> Can someone please provide a reproducing example for this case? Or add the missing information to my given example?
          Hide
          cor3000 cor3000 added a comment -

          Another user reported:

          org.zkoss.zkmax.au.websocket.WebSocketEndPoint onError
          AVVERTENZA: SERVER ERROR
          java.lang.NullPointerException
              at org.apache.catalina.connector.Response.setLocale(Response.java:833)
              at org.apache.catalina.connector.ResponseFacade.setLocale(ResponseFacade.java:369)
              at org.zkoss.web.servlet.Charsets.setup(Charsets.java:92)
              at org.zkoss.zk.ui.http.I18Ns.setup(I18Ns.java:119)
              at org.zkoss.zk.ui.http.I18Ns.setup(I18Ns.java:66)
              at org.zkoss.zkmax.au.websocket.WebSocketEndPoint$1.onMessage(WebSocketEndPoint.java:104)
              at org.zkoss.zkmax.au.websocket.WebSocketEndPoint$1.onMessage(WebSocketEndPoint.java:102)
              at org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:393)
              at org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:494)
              at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:289)
              at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:130)
          
          Show
          cor3000 cor3000 added a comment - Another user reported: org.zkoss.zkmax.au.websocket.WebSocketEndPoint onError AVVERTENZA: SERVER ERROR java.lang.NullPointerException at org.apache.catalina.connector.Response.setLocale(Response.java:833) at org.apache.catalina.connector.ResponseFacade.setLocale(ResponseFacade.java:369) at org.zkoss.web.servlet.Charsets.setup(Charsets.java:92) at org.zkoss.zk.ui.http.I18Ns.setup(I18Ns.java:119) at org.zkoss.zk.ui.http.I18Ns.setup(I18Ns.java:66) at org.zkoss.zkmax.au.websocket.WebSocketEndPoint$1.onMessage(WebSocketEndPoint.java:104) at org.zkoss.zkmax.au.websocket.WebSocketEndPoint$1.onMessage(WebSocketEndPoint.java:102) at org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:393) at org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:494) at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:289) at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:130)
          Hide
          JoseWalker JoseWalker added a comment -

          This the error we're getting:

          08-Mar-2018 10:12:52.931 WARNING [http-nio-8180-exec-1] org.zkoss.zkmax.au.websocket.WebSocketEndPoint.onError SERVER ERROR
          java.lang.NullPointerException
          at org.apache.catalina.connector.Response.setLocale(Response.java:814)
          at org.apache.catalina.connector.ResponseFacade.setLocale(ResponseFacade.java:369)
          at org.zkoss.web.servlet.Charsets.setup(Charsets.java:92)
          at org.zkoss.zk.ui.http.I18Ns.setup(I18Ns.java:119)
          at org.zkoss.zk.ui.http.I18Ns.setup(I18Ns.java:66)
          at org.zkoss.zkmax.au.websocket.WebSocketEndPoint$1.onMessage(WebSocketEndPoint.java:104)
          at org.zkoss.zkmax.au.websocket.WebSocketEndPoint$1.onMessage(WebSocketEndPoint.java:102)
          at org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:399)
          at org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:500)
          at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:295)
          at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:131)
          at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:71)
          at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler$WsReadListener.onDataAvailable(WsHttpUpgradeHandler.java:185)
          at org.apache.coyote.http11.upgrade.AbstractServletInputStream.onDataAvailable(AbstractServletInputStream.java:198)
          at org.apache.coyote.http11.upgrade.AbstractProcessor.upgradeDispatch(AbstractProcessor.java:96)
          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:647)
          at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
          at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
          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)

          Show
          JoseWalker JoseWalker added a comment - This the error we're getting: 08-Mar-2018 10:12:52.931 WARNING [http-nio-8180-exec-1] org.zkoss.zkmax.au.websocket.WebSocketEndPoint.onError SERVER ERROR java.lang.NullPointerException at org.apache.catalina.connector.Response.setLocale(Response.java:814) at org.apache.catalina.connector.ResponseFacade.setLocale(ResponseFacade.java:369) at org.zkoss.web.servlet.Charsets.setup(Charsets.java:92) at org.zkoss.zk.ui.http.I18Ns.setup(I18Ns.java:119) at org.zkoss.zk.ui.http.I18Ns.setup(I18Ns.java:66) at org.zkoss.zkmax.au.websocket.WebSocketEndPoint$1.onMessage(WebSocketEndPoint.java:104) at org.zkoss.zkmax.au.websocket.WebSocketEndPoint$1.onMessage(WebSocketEndPoint.java:102) at org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:399) at org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:500) at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:295) at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:131) at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:71) at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler$WsReadListener.onDataAvailable(WsHttpUpgradeHandler.java:185) at org.apache.coyote.http11.upgrade.AbstractServletInputStream.onDataAvailable(AbstractServletInputStream.java:198) at org.apache.coyote.http11.upgrade.AbstractProcessor.upgradeDispatch(AbstractProcessor.java:96) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:647) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476) 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)
          Hide
          cor3000 cor3000 added a comment - - edited

          when using Apache Tomcat 8.5 (8.5.23/8.5.28) the following button, triggering a WS request will cause the NPE exception in 8.5.1 (not 8.5.0)

          <zk>
          	<button label="trigger au" onClick=""/>
          </zk>
          

          The problem doesn't occur when testing with Jetty 9.4.8.v20171121

          Show
          cor3000 cor3000 added a comment - - edited when using Apache Tomcat 8.5 (8.5.23/8.5.28) the following button, triggering a WS request will cause the NPE exception in 8.5.1 (not 8.5.0) <zk> <button label= "trigger au" onClick=""/> </zk> The problem doesn't occur when testing with Jetty 9.4.8.v20171121
          Hide
          rudyhuang rudyhuang added a comment -

          Fixed since 2017/03/19 (included in 0316 FL)

          Show
          rudyhuang rudyhuang added a comment - Fixed since 2017/03/19 (included in 0316 FL)

            People

            • Assignee:
              wenninghsu wenninghsu
              Reporter:
              afxgroup afxgroup
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: