-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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.
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.
Asked: 2017-10-04 21:14:15 +0800
Seen: 13 times
Last updated: Oct 05 '17