[GLASSFISH-20468] Can't send a JMS message from WebSocket's onMessage Created: 05/May/13 Updated: 20/Dec/16
|Fix Version/s:||future release|
|Remaining Estimate:||Not Specified|
|Time Spent:||Not Specified|
|Original Estimate:||Not Specified|
The following code fails to send an incoming WebSocket message to a JMS queue:
This is the exception (not logged by GF due to
Because JMSContext is @RequestScoped, and a WebSocket message has the same behaviour as an HTTP request, it should be possible to use the injected JMSContext to send a message to a Queue from WebSocket.onMessage method.
The following code works fine:
|Comment by jjsnyder83 [ 06/May/13 ]|
The @Resource works because it's a resource injection of an object that is in JNDI. It is not a CDI-scoped injected object.
The @Inject fails for the same reason as: https://java.net/jira/browse/GLASSFISH-20371
|Comment by jjsnyder83 [ 08/May/13 ]|
This will require a CDI spec change. See https://issues.jboss.org/browse/CDI-370
|Comment by jjsnyder83 [ 18/Jun/13 ]|
This issue really is a usage issue of the JMSContext. The JMSContext requires a global Transaction or an active CDI request context. At the time the injected JMSContext is being used there is no global transaction and no active CDI request context and so the exception is thrown.
There is ongoing discussions on whether the CDI request context can be expanded to account for WebSocket and if WebSocket needs to create its own CDI scope. In any case this issue is a usage issue irt how WebSocket uses the JMSContext.