Publish to ZK EventQueue from EJB?

asked 2017-10-04 21:14:15 +0800

tisaksen gravatar image tisaksen
46 6

I have an EJB from which I am trying to access the EventQueue of ZKoss. I use the following call:

EventQueue myQueue = EventQueues.lokup("MY_QUEUE", EventQueues.APPLICATION, true);

The call fails with this stacktrace:

2017-10-04 14:27:43,731 ERROR [no.company.app.jms.OSBCallbackMonitorBean] Exception during onMessage handling. java.lang.IllegalStateException: Not in an execution at org.zkoss.zk.ui.event.impl.EventQueueProviderImpl.lookup(EventQueueProviderImpl.java:65) ~[zk-8.0.5.jar:8.0.5] at org.zkoss.zkmax.ui.event.impl.EventQueueProviderImpl.lookup(EventQueueProviderImpl.java:57) ~[zkmax-8.0.5.jar:?] at org.zkoss.zk.ui.event.EventQueues.lookup(EventQueues.java:130) ~[zk-8.0.5.jar:8.0.5] at org.zkoss.zk.ui.event.EventQueues.lookup(EventQueues.java:166) ~[zk-8.0.5.jar:8.0.5] at no.company.app.jms.OSBCallbackMonitorBean.notifyClient(OSBCallbackMonitorBean.java:117) ~[wlcls_gen.jar:?]

Is it not possible to access the event queue of ZK without an Execution? If not, any suggestions to how I might solve this? The EJB simply needs to tell ZK that there has been an update.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-10-05 11:41:20 +0800

cor3000 gravatar image cor3000
5868 2 7
ZK Team

updated 2017-10-05 11:49:22 +0800

Here the related javadoc:

This method can be called only in an activated execution, i.e., Executions.getCurrent() not null. If you want to use it without an execution, please use lookup(String, Session, boolean) or lookup(String, WebApp, boolean) instead (depending on your scope).

This means you can use an alternative API method to retrieve an application scoped event queue by passing in a WebApp instance instead of a String: EventQueues#lookup(String, WebApp, boolean)

Unlike lookup(String, String, boolean), this method can be called without an activated execution.

So this should be possible from within your webapp:

EventQueue myQueue = EventQueues.lookup("MY_QUEUE", WebApps.getCurrent(), true);

This might still fail depending on configuration (e.g. your EJB module might be deployed remotely or in an isolated classloader) ... Please give it a try and let me know if the problem persists.

link publish delete flag offensive edit


Awesome! It's working now. Thank you so much for your help! :-)

tisaksen ( 2017-10-05 14:58:42 +0800 )edit

you're welcome

cor3000 ( 2017-10-05 15:24:38 +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




Asked: 2017-10-04 21:14:15 +0800

Seen: 13 times

Last updated: Oct 05 '17

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