0

CometServerPush problem

asked 2014-02-24 12:39:03 +0800

Tristan2583 gravatar image Tristan2583
13 3

Hi all! I had to use zk server push feature and i've done a stupid project, just to try. There's a poster of event on a queue and a receiver that "manage" the event.

poster.zul:

<window title="points generator" border="normal" width="100%"
    height="100%" apply="org.zkoss.bind.BindComposer"
    viewModel="@id('vm') @init('PosterVM')">

<button id="gen" label="post an event" onClick="@command('postEvent')" />

</window>

receiver.zul:

<window title="points generator" border="normal" width="100%"
    height="100%" apply="org.zkoss.bind.BindComposer"
    viewModel="@id('vm') @init('ReceiverVM')" onServerPush="@command('doServerPush')">

    <label value="@load(vm.label)"></label>

</window>

PosterVM.java:

public class PosterVM {

EventQueue<Event> eq = EventQueues.lookup("francis queue", EventQueues.APPLICATION, true);                           
@Command
public void postEvent(){
    eq.publish( new Event( "onStiCazzi" ) );    
}

}

ReceiverVM:

public class ReceiverVM {

private String label;
private EventQueue<Event> eq = EventQueues.lookup("francis queue", EventQueues.APPLICATION, true);

@Init
public void init(){
    label = "No points received";
    eq.subscribe( new FrancisEventListener<Event>() );

}

@Command
@NotifyChange("label")
public void doServerPush(@ContextParam(ContextType.TRIGGER_EVENT) Event evt){

    int ret = (int) evt.getData();
    label = "Point received: ".concat( Integer.toString(ret) );

}

}

FrancisEventListener.java:

public class FrancisEventListener<T extends Event> implements EventListener<Event>{

@Override
public void onEvent(Event event) throws Exception {

    try{
        Random r = new Random();
        Executions.getCurrent().postEvent(new Event("onServerPush", null, r.nextInt(100)));

    }
    catch (ClassCastException e){
        e.printStackTrace();
    }

}

}

Sometimes ( not always! ) when I restart tomcat I get this:

SEVERE:

java.lang.NullPointerException at org.zkoss.zkmax.ui.comet.CometAsyncServlet$AsyncInfo.complete(CometAsyncServlet.java:150) at org.zkoss.zkex.ui.comet.CometServerPush.cleanAsyncInfo(CometServerPush.java:340) at org.zkoss.zkex.ui.comet.CometServerPush.schedule(CometServerPush.java:229) at org.zkoss.zk.ui.impl.DesktopImpl.scheduleServerPush(DesktopImpl.java:1469) at org.zkoss.zk.ui.Executions.schedule(Executions.java:873) at org.zkoss.zk.ui.event.impl.ServerPushEventQueue$DesktopInfo.publish(ServerPushEventQueue.java:157) at org.zkoss.zk.ui.event.impl.ServerPushEventQueue$DesktopInfo.access$000(ServerPushEventQueue.java:137) at org.zkoss.zk.ui.event.impl.ServerPushEventQueue.publish(ServerPushEventQueue.java:53) at PosterVM.postEvent(PosterVM.java:11) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.zkoss.bind.impl.ParamCall.call(ParamCall.java:111) at org.zkoss.bind.impl.BinderImpl.doExecute(BinderImpl.java:1745) at org.zkoss.bind.impl.BinderImpl.doCommand(BinderImpl.java:1506) at org.zkoss.bind.impl.BinderImpl.access$1500(BinderImpl.java:107) at org.zkoss.bind.impl.BinderImpl$CommandEventListener.onEvent0(BinderImpl.java:1375) at org.zkoss.bind.impl.BinderImpl$CommandEventListener.onEvent(BinderImpl.java:1327) at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:2743) at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2714) at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2655) at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:136) at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1721) at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1506) at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1216) at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:601) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:483) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:492) at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) 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:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

feb 24, 2014 1:34:56 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [CometAsyncServlet] in context with path [/ServerPush] threw exception java.lang.NullPointerException at org.zkoss.zkmax.ui.comet.CometAsyncServlet$AsyncInfo.complete(CometAsyncServlet.java:150) at org.zkoss.zkex.ui.comet.CometServerPush.cleanAsyncInfo(CometServerPush.java:340) at org.zkoss.zkex.ui.comet.CometServerPush.processRequest(CometServerPush.java:271) at org.zkoss.zkmax.ui.comet.CometServerPush.processRequest(CometServerPush.java:106) at org.zkoss.zkmax.ui.comet.CometAsyncServlet.doPost(CometAsyncServlet.java:116) at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) 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:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

feb 24, 2014 1:34:56 PM org.zkoss.bind.impl.BinderImpl$CommandEventListener onEvent:1329 SEVERE: null java.lang.NullPointerException at org.zkoss.zkmax.ui.comet.CometAsyncServlet$AsyncInfo.complete(CometAsyncServlet.java:150) at org.zkoss.zkex.ui.comet.CometServerPush.cleanAsyncInfo(CometServerPush.java:340) at org.zkoss.zkex.ui.comet.CometServerPush.schedule(CometServerPush.java:229) at org.zkoss.zk.ui.impl.DesktopImpl.scheduleServerPush(DesktopImpl.java:1469) at org.zkoss.zk.ui.Executions.schedule(Executions.java:873) at org.zkoss.zk.ui.event.impl.ServerPushEventQueue$DesktopInfo.publish(ServerPushEventQueue.java:157) at org.zkoss.zk.ui.event.impl.ServerPushEventQueue$DesktopInfo.access$000(ServerPushEventQueue.java:137) at org.zkoss.zk.ui.event.impl.ServerPushEventQueue.publish(ServerPushEventQueue.java:53) at PosterVM.postEvent(PosterVM.java:11) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.zkoss.bind.impl.ParamCall.call(ParamCall.java:111) at org.zkoss.bind.impl.BinderImpl.doExecute(BinderImpl.java:1745) at org.zkoss.bind.impl.BinderImpl.doCommand(BinderImpl.java:1506) at org.zkoss.bind.impl.BinderImpl.access$1500(BinderImpl.java:107) at org.zkoss.bind.impl.BinderImpl$CommandEventListener.onEvent0(BinderImpl.java:1375) at org.zkoss.bind.impl.BinderImpl$CommandEventListener.onEvent(BinderImpl.java:1327) at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:2743) at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2714) at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2655) at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:136) at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1721) at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1506) at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1216) at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:601) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:483) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:492) at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) 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:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

feb 24, 2014 1:34:56 PM org.zkoss.zk.ui.impl.UiEngineImpl handleError:1363 SEVERE: >>java.lang.NullPointerException

at org.zkoss.zkmax.ui.comet.CometAsyncServlet$AsyncInfo.complete(CometAsyncServlet.java:150) at org.zkoss.zkex.ui.comet.CometServerPush.cleanAsyncInfo(CometServerPush.java:340) at org.zkoss.zkex.ui.comet.CometServerPush.schedule(CometServerPush.java:229) at org.zkoss.zk.ui.impl.DesktopImpl.scheduleServerPush(DesktopImpl.java:1469) at org.zkoss.zk.ui.Executions.schedule(Executions.java:873) at org.zkoss.zk.ui.event.impl.ServerPushEventQueue$DesktopInfo.publish(ServerPushEventQueue.java:157) at org.zkoss.zk.ui.event.impl.ServerPushEventQueue$DesktopInfo.access$000(ServerPushEventQueue.java:137) at org.zkoss.zk.ui.event.impl.ServerPushEventQueue.publish(ServerPushEventQueue.java:53) at PosterVM.postEvent(PosterVM.java:11) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.zkoss.bind.impl.ParamCall.call(ParamCall.java:111) at org.zkoss.bind.impl.BinderImpl.doExecute(BinderImpl.java:1745) at org.zkoss.bind.impl.BinderImpl.doCommand(BinderImpl.java:1506) at org.zkoss.bind.impl.BinderImpl.access$1500(BinderImpl.java:107) at org.zkoss.bind.impl.BinderImpl$CommandEventListener.onEvent0(BinderImpl.java:1375) at org.zkoss.bind.impl.BinderImpl$CommandEventListener.onEvent(BinderImpl.java:1327) at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:2743) at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2714) at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2655) at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:136) at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1721) at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1506) at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1216) at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:601) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:483) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:492) at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) 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:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

For the most of time all work well.. But sometimes this strange thing happen!

P.S. I use ZK EE 6.5.5

delete flag offensive retag edit

2 Answers

Sort by » oldest newest most voted
3

answered 2014-02-24 13:37:35 +0800

chillworld gravatar image chillworld flag of Belgium
5337 4 9
https://github.com/chillw...

updated 2014-03-04 08:14:48 +0800

Can it be that you have a servlet named ServletPush declared in your web.xml? (this can be your problem)
Read this small talk : http://books.zkoss.org/wiki/SmallTalks/2009/August/ZK5:ChatwithEventQueue and you will see that there are no servlets configured.

Then a suggestion four your coding(it will be easier and cleaner to maintain) :

Actually you don't need the eventQueue in your java code cause you are working in MVVM, server push can also be done with global-commands.

Read this question: http://forum.zkoss.org/question/90813/postglobalcommand-in-application-scope/

If you have questions about this approuch let me know(small talk is coming for that topic).

edit :

I reviewed your program and there is nothing wrong with it. As I can see in the stacktrace you have another webprogram deployed on your tomcat. That program calls CometAsyncServlet at the path /ServerPush(the program you send calls ServerPush and path is / ).

Now go to your tomcat and undeploy that webprogram and you will have no error when restarting your tomcat.

Greetz chill.

link publish delete flag offensive edit
0

answered 2014-03-02 09:51:04 +0800

Tristan2583 gravatar image Tristan2583
13 3

I don't have any servlet named "ServletPush" declared in my web.xml. I'll look for the solution with global commands but I'd like to know why this problem happens.

link publish delete flag offensive edit

Comments

if its a test project, can you post in on dropbox/google drive/... in a zip file? I shall download it and review where the fault come from. Normally changing your code to the global- command will not solve your problem. Greetrz chill.

chillworld ( 2014-03-02 10:21:32 +0800 )edit

I've zipped and uploaded the entire ( stupid ) eclipse project on google drive. That's the link: https://drive.google.com/folderview?id=0B63v7RiKCWbvT3Y4bjRPY3N4T0E&usp=sharing

Thanks so much for your help!

Tristan2583 ( 2014-03-03 16:45:09 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2014-02-24 12:39:03 +0800

Seen: 77 times

Last updated: Mar 18 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More