users@tyrus.java.net

CDI Interceptor on a WebSocket endpoint

From: Arun Gupta <arun.p.gupta_at_oracle.com>
Date: Sat, 16 Feb 2013 17:42:06 -0800

Deployed a POJO endpoint as defined at:

@WebSocketEndpoint(value="/websocket-cdi")
@Logging
public class MyEndpointWithCDI {

     @Inject MyBean bean;

     @WebSocketMessage
     public String sayHello(String name) {
         return bean.sayHello(name);
     }
}

@Logging is a standard CDI interceptor with @AroundInvoke and MyBean is
a POJO. Deploying this application throws the following exception:

INFO: Closing down : org.glassfish.tyrus.server.TyrusEndpoint_at_361cb3dd
INFO: Closing down : org.glassfish.tyrus.server.TyrusEndpoint_at_23a18c70
SEVERE: Exception during invocation of
InjectionManager.destroyManagedObject on
org.glassfish.tyrus.servlet.TyrusServletFilter_at_2add39c5 of web module
StandardEngine[glassfish-web].StandardHost[server].StandardContext[/injection]
java.lang.IllegalStateException: Unknown JCDI-enabled managed bean
org.glassfish.tyrus.servlet.TyrusServletFilter_at_2add39c5 of class class
org.glassfish.tyrus.servlet.TyrusServletFilter
     at
com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.destroyManagedBean(ManagedBeanManagerImpl.java:622)
     at
com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.destroyManagedObject(InjectionManagerImpl.java:439)
     at
com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.destroyManagedObject(InjectionManagerImpl.java:414)
     at
com.sun.web.server.WebContainerListener.preDestroy(WebContainerListener.java:186)
     at
com.sun.web.server.WebContainerListener.containerEvent(WebContainerListener.java:151)
     at
org.apache.catalina.core.ContainerBase.fireContainerEvent(ContainerBase.java:1579)
     at
org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:334)
     at
org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:5322)
     at
org.apache.catalina.core.StandardContext.stop(StandardContext.java:6085)

Invoking the endpoint throws the following message in server.log:

SEVERE: No valid EE environment for injection of
org.glassfish.injection.MyEndpointWithCDI
SEVERE: No valid EE environment for injection of
org.glassfish.injection.MyBean

However the communication between client and endpoint works as expected.

What should happen if a CDI interceptor is enabled on a WebSocket endpoint ?

Arun

-- 
http://twitter.com/arungupta
http://blogs.oracle.com/arungupta